Class

Symfony\Bundle\DoctrineBundle\Registry

class Registry implements RegistryInterface

References all Doctrine connections and entity managers in a given Container.

Methods

__construct(ContainerInterface $container, array $connections, array $entityManagers, $defaultConnection, $defaultEntityManager)

string getDefaultConnectionName()

Gets the default connection name.

Connection getConnection(string $name = null)

Gets the named connection.

array getConnections()

Gets an array of all registered connections

array getConnectionNames()

Gets all connection names.

string getDefaultEntityManagerName()

Gets the default entity manager name.

EntityManager getEntityManager(string $name = null)

Gets a named entity manager.

array getEntityManagers()

Gets an array of all registered entity managers

EntityManager resetEntityManager(string $name = null)

Resets a named entity manager.

string getEntityNamespace(string $alias)

Resolves a registered namespace alias to the full namespace.

array getEntityManagerNames()

Gets all connection names.

EntityRepository getRepository(string $entityName, string $entityManagerName = null)

Gets the EntityRepository for an entity.

EntityManager|null getEntityManagerForClass(string $class)

Gets the entity manager associated with a given class.

Details

at line 35
public __construct(ContainerInterface $container, array $connections, array $entityManagers, $defaultConnection, $defaultEntityManager)

Parameters

ContainerInterface $container
array $connections
array $entityManagers
$defaultConnection
$defaultEntityManager

at line 49
public string getDefaultConnectionName()

Gets the default connection name.

Return Value

string The default connection name

at line 61
public Connection getConnection(string $name = null)

Gets the named connection.

Parameters

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

Return Value

Connection

at line 79
public array getConnections()

Gets an array of all registered connections

Return Value

array An array of Connection instances

at line 94
public array getConnectionNames()

Gets all connection names.

Return Value

array An array of connection names

at line 104
public string getDefaultEntityManagerName()

Gets the default entity manager name.

Return Value

string The default entity manager name

at line 116
public EntityManager getEntityManager(string $name = null)

Gets a named entity manager.

Parameters

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

Return Value

EntityManager

at line 134
public array getEntityManagers()

Gets an array of all registered entity managers

Return Value

array An array of EntityManager instances

at line 161
public EntityManager resetEntityManager(string $name = null)

Resets a named entity manager.

This method is useful when an entity 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 entity manager as the existing one is not useable anymore. This means that any other object with a dependency on this entity manager will hold an obsolete reference. You can inject the registry instead to avoid this problem.

Parameters

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

Return Value

EntityManager

at line 187
public string getEntityNamespace(string $alias)

Resolves a registered namespace alias to the full namespace.

This method looks for the alias in all registered entity managers.

Parameters

string $alias The alias

Return Value

string The full namespace

See also

Configuration::getEntityNamespace

at line 204
public array getEntityManagerNames()

Gets all connection names.

Return Value

array An array of connection names

at line 217
public EntityRepository getRepository(string $entityName, string $entityManagerName = null)

Gets the EntityRepository for an entity.

Parameters

string $entityName The name of the entity.
string $entityManagerName The entity manager name (null for the default one)

Return Value

EntityRepository

at line 229
public EntityManager|null getEntityManagerForClass(string $class)

Gets the entity manager associated with a given class.

Parameters

string $class A Doctrine Entity class name

Return Value

EntityManager|null