2019-01-20 13:33:33 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Domain\RepositoryManagement;
|
|
|
|
|
|
|
|
use App\Repository\RepositoryInterface;
|
|
|
|
use Doctrine\ORM\EntityManagerInterface;
|
2019-01-26 17:07:16 +01:00
|
|
|
use App\Domain\LayerManagement\LayerClassMap;
|
2019-01-20 13:33:33 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @author kevinfrantz
|
|
|
|
*/
|
|
|
|
final class LayerRepositoryFactoryService implements LayerRepositoryFactoryServiceInterface
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var EntityManagerInterface
|
|
|
|
*/
|
|
|
|
private $entityManager;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param EntityManagerInterface $entityManager
|
|
|
|
*/
|
|
|
|
public function __construct(EntityManagerInterface $entityManager)
|
|
|
|
{
|
|
|
|
$this->entityManager = $entityManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $layer
|
|
|
|
*
|
|
|
|
* @return RepositoryInterface
|
|
|
|
*/
|
|
|
|
public function getRepository(string $layer): RepositoryInterface
|
|
|
|
{
|
2019-01-26 17:07:16 +01:00
|
|
|
$repositoryClassName = LayerClassMap::getClass($layer);
|
2019-01-20 13:33:33 +01:00
|
|
|
|
|
|
|
return $this->entityManager->getRepository($repositoryClassName);
|
|
|
|
}
|
|
|
|
}
|