mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-10 06:27:24 +01:00
Used LayerClassMap
This commit is contained in:
parent
a59d803d96
commit
09944d032c
@ -4,40 +4,18 @@ namespace App\Domain\RepositoryManagement;
|
|||||||
|
|
||||||
use App\Repository\RepositoryInterface;
|
use App\Repository\RepositoryInterface;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use App\DBAL\Types\Meta\Right\LayerType;
|
use App\Domain\LayerManagement\LayerClassMap;
|
||||||
use App\Exception\NotSetException;
|
|
||||||
use App\Entity\Source\AbstractSource;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*/
|
*/
|
||||||
final class LayerRepositoryFactoryService implements LayerRepositoryFactoryServiceInterface
|
final class LayerRepositoryFactoryService implements LayerRepositoryFactoryServiceInterface
|
||||||
{
|
{
|
||||||
const LAYER_CLASS_MAP = [
|
|
||||||
LayerType::SOURCE => AbstractSource::class,
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var EntityManagerInterface
|
* @var EntityManagerInterface
|
||||||
*/
|
*/
|
||||||
private $entityManager;
|
private $entityManager;
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $layer
|
|
||||||
*
|
|
||||||
* @throws NotSetException
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private function getRepositoryClassName(string $layer): string
|
|
||||||
{
|
|
||||||
$map = self::LAYER_CLASS_MAP;
|
|
||||||
if (array_key_exists($layer, $map)) {
|
|
||||||
return $map[$layer];
|
|
||||||
}
|
|
||||||
throw new NotSetException('The requested layer is not mapped!');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param EntityManagerInterface $entityManager
|
* @param EntityManagerInterface $entityManager
|
||||||
*/
|
*/
|
||||||
@ -53,7 +31,7 @@ final class LayerRepositoryFactoryService implements LayerRepositoryFactoryServi
|
|||||||
*/
|
*/
|
||||||
public function getRepository(string $layer): RepositoryInterface
|
public function getRepository(string $layer): RepositoryInterface
|
||||||
{
|
{
|
||||||
$repositoryClassName = $this->getRepositoryClassName($layer);
|
$repositoryClassName = LayerClassMap::getClass($layer);
|
||||||
|
|
||||||
return $this->entityManager->getRepository($repositoryClassName);
|
return $this->entityManager->getRepository($repositoryClassName);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user