You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
755 B

<?php
namespace Common;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityRepository;
/**
* Factory for doctrine repositories - provides adapter for the service locator pattern used
* to access repositories via entity manager, for the ability to use repositories in DI container
*
* @author Jan Pavlíček <jan.pavlicek@altekpro.cz>
* @since 1.0.0
*/
class EntityRepositoryFactory
{
/**
* @var Doctrine\ORM\EntityManager
*/
protected $em;
public function __construct(EntityManager $em)
{
$this->em = $em;
}
/**
* Creates the repository using entity manager
*/
public function create(string $class) : EntityRepository
{
return $this->em->getRepository($class);
}
}