infinito/application/symfony/src/Domain/RepositoryManagement/LayerRepositoryFactoryService.php

39 lines
892 B
PHP
Raw Normal View History

<?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;
/**
* @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);
return $this->entityManager->getRepository($repositoryClassName);
}
}