abstract class AbstractManagerRegistry implements ManagerRegistry (View source)

Abstract implementation of the ManagerRegistry contract.

Methods

__construct(string $name, array $connections, array $managers, string $defaultConnection, string $defaultManager, string $proxyInterfaceName)

Constructor

object
getService(string $name)

Fetches/creates the given services

void
resetService(string $name)

Resets the given services

string
getName()

Get the name of the registry

object
getConnection(string $name = null)

Gets the named connection.

array
getConnectionNames()

Gets all connection names.

array
getConnections()

Gets an array of all registered connections

string
getDefaultConnectionName()

Gets the default connection name.

string
getDefaultManagerName()

Gets the default object manager name.

getManager(string $name = null)

Gets a named object manager.

getManagerForClass(string $class)

Gets the object manager associated with a given class.

array
getManagerNames()

Gets all connection names.

getManagers()

Gets an array of all registered object managers

getRepository($persistentObjectName, string $persistentManagerName = null)

Gets the ObjectRepository for an persistent object.

resetManager(string $name = null)

Resets a named object manager.

Details

__construct(string $name, array $connections, array $managers, string $defaultConnection, string $defaultManager, string $proxyInterfaceName)

Constructor

Parameters

string $name
array $connections
array $managers
string $defaultConnection
string $defaultManager
string $proxyInterfaceName

abstract protected object getService(string $name)

Fetches/creates the given services

A service in this context is connection or a manager instance

Parameters

string $name name of the service

Return Value

object instance of the given service

abstract protected void resetService(string $name)

Resets the given services

A service in this context is connection or a manager instance

Parameters

string $name name of the service

Return Value

void

string getName()

Get the name of the registry

Return Value

string

object getConnection(string $name = null)

Gets the named connection.

Parameters

string $name The connection name (null for the default one)

Return Value

object

array getConnectionNames()

Gets all connection names.

Return Value

array An array of connection names

array getConnections()

Gets an array of all registered connections

Return Value

array An array of Connection instances

string getDefaultConnectionName()

Gets the default connection name.

Return Value

string The default connection name

string getDefaultManagerName()

Gets the default object manager name.

Return Value

string The default object manager name

ObjectManager getManager(string $name = null)

Gets a named object manager.

Parameters

string $name The object manager name (null for the default one)

Return Value

ObjectManager

ObjectManager|null getManagerForClass(string $class)

Gets the object manager associated with a given class.

Parameters

string $class A persistent object class name

Return Value

ObjectManager|null

array getManagerNames()

Gets all connection names.

Return Value

array An array of connection names

ObjectManager[] getManagers()

Gets an array of all registered object managers

Return Value

ObjectManager[] An array of ObjectManager instances

ObjectRepository getRepository($persistentObjectName, string $persistentManagerName = null)

Gets the ObjectRepository for an persistent object.

Parameters

$persistentObjectName
string $persistentManagerName The object manager name (null for the default one)

Return Value

ObjectRepository

ObjectManager resetManager(string $name = null)

Resets a named object manager.

This method is useful when an object manager has been closed because of a rollbacked transaction AND when you think that it makes sense to get a new one to replace the closed one.

Be warned that you will get a brand new object manager as the existing one is not useable anymore. This means that any other object with a dependency on this object manager will hold an obsolete reference. You can inject the registry instead to avoid this problem.

Parameters

string $name The object manager name (null for the default one)

Return Value

ObjectManager