ManagerRegistry
extends
ConnectionRegistry
in
Contract covering object managers for a Doctrine persistence layer ManagerRegistry class to implement.
Table of Contents
Methods
- getConnection() : object
- Gets the named connection.
- getConnectionNames() : array<string, string>
- Gets all connection names.
- getConnections() : array<string, object>
- Gets an array of all registered connections.
- getDefaultConnectionName() : string
- Gets the default connection name.
- getDefaultManagerName() : string
- Gets the default object manager name.
- getManager() : ObjectManager
- Gets a named object manager.
- getManagerForClass() : ObjectManager|null
- Gets the object manager associated with a given class.
- getManagerNames() : array<string, string>
- Gets all object manager names and associated service IDs. A service ID is a string that allows to obtain an object manager, typically from a PSR-11 container.
- getManagers() : array<string, ObjectManager>
- Gets an array of all registered object managers.
- getRepository() : ObjectRepository
- Gets the ObjectRepository for a persistent object.
- resetManager() : ObjectManager
- Resets a named object manager.
Methods
getConnection()
Gets the named connection.
public
getConnection([string|null $name = null ]) : object
Parameters
- $name : string|null = null
-
The connection name (null for the default one).
Return values
objectgetConnectionNames()
Gets all connection names.
public
getConnectionNames() : array<string, string>
Return values
array<string, string> —An array of connection names.
getConnections()
Gets an array of all registered connections.
public
getConnections() : array<string, object>
Return values
array<string, object> —An array of Connection instances.
getDefaultConnectionName()
Gets the default connection name.
public
getDefaultConnectionName() : string
Return values
string —The default connection name.
getDefaultManagerName()
Gets the default object manager name.
public
getDefaultManagerName() : string
Return values
string —The default object manager name.
getManager()
Gets a named object manager.
public
getManager([string|null $name = null ]) : ObjectManager
Parameters
- $name : string|null = null
-
The object manager name (null for the default one).
Return values
ObjectManagergetManagerForClass()
Gets the object manager associated with a given class.
public
getManagerForClass(class-string $class) : ObjectManager|null
Parameters
- $class : class-string
-
A persistent object class name.
Return values
ObjectManager|nullgetManagerNames()
Gets all object manager names and associated service IDs. A service ID is a string that allows to obtain an object manager, typically from a PSR-11 container.
public
getManagerNames() : array<string, string>
Return values
array<string, string> —An array with object manager names as keys, and service IDs as values.
getManagers()
Gets an array of all registered object managers.
public
getManagers() : array<string, ObjectManager>
Return values
array<string, ObjectManager> —An array of ObjectManager instances
getRepository()
Gets the ObjectRepository for a persistent object.
public
getRepository(string $persistentObject[, string|null $persistentManagerName = null ]) : ObjectRepository
Parameters
- $persistentObject : string
-
The name of the persistent object.
- $persistentManagerName : string|null = null
-
The object manager name (null for the default one).
Tags
Return values
ObjectRepositoryresetManager()
Resets a named object manager.
public
resetManager([string|null $name = null ]) : ObjectManager
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
- $name : string|null = null
-
The object manager name (null for the default one).