ContainerRepositoryFactory
in package
implements
RepositoryFactory
FinalYes
Fetches repositories from the container or falls back to normal creation.
Table of Contents
Interfaces
- RepositoryFactory
- Interface for entity repository factory.
Properties
- $container : ContainerInterface
- $managedRepositories : array<string, ObjectRepository>
Methods
- __construct() : mixed
- getRepository() : ObjectRepository<string|int, T>
- Gets the repository for an entity class.
- getOrCreateRepository() : ObjectRepository<string|int, TEntity>
Properties
$container
private
ContainerInterface
$container
$managedRepositories
private
array<string, ObjectRepository>
$managedRepositories
= []
Methods
__construct()
public
__construct(ContainerInterface $container) : mixed
Parameters
- $container : ContainerInterface
-
A service locator containing the repositories
getRepository()
Gets the repository for an entity class.
public
getRepository(EntityManagerInterface $entityManager, mixed $entityName) : ObjectRepository<string|int, T>
Parameters
- $entityManager : EntityManagerInterface
-
The EntityManager instance.
- $entityName : mixed
-
The name of the entity.
Tags
Return values
ObjectRepository<string|int, T> —This type will change to EntityRepository in 3.0.
getOrCreateRepository()
private
getOrCreateRepository(EntityManagerInterface $entityManager, ClassMetadata<string|int, TEntity> $metadata) : ObjectRepository<string|int, TEntity>
Parameters
- $entityManager : EntityManagerInterface
- $metadata : ClassMetadata<string|int, TEntity>