src/Service/Common/Owner/OwnerProvider.php line 35
<?phpnamespace App\Service\Common\Owner;use App\Entity\UUID\Owners;use App\Model\Common\OwnerModel;use App\Model\Common\OwnerInterface;use Doctrine\ORM\EntityManagerInterface;use Doctrine\ORM\NoResultException;use Doctrine\ORM\QueryBuilder;use Symfony\Component\PropertyAccess\PropertyAccessor;class OwnerProvider{/*** @var PropertyAccessor*/private $pa;/*** @var \App\Service\Common\Owner\OwnerFactory*/private $config;/*** @var EntityManagerInterface*/private $em;public function __construct(\App\Service\Common\Owner\OwnerFactory $ownerNewsConfig, EntityManagerInterface $em){$this->pa = new PropertyAccessor();$this->config = $ownerNewsConfig;$this->em = $em;}public function findOwner(OwnerInterface $owner): ?OwnerModel{if ($owner->getUuid()) {return $this->findByUuid($owner->getUuid());}return null;}public function findByUuid(string $uuid): ?OwnerModel{try {$type = $this->em->getRepository(Owners::class)->findType($uuid);// dump($type);$cfg = $this->config->get($type);// dump($cfg);$ent = $this->em->getRepository($cfg->getClass())->{$cfg->getRepositorySingle()}($uuid);if ($ent) {return new OwnerModel($ent, $cfg->getRender());}} catch (NoResultException $ex) {return null;}return null;}public function getTitles(){// return array_column($this->config->all(), 'title','name');$res = [];foreach ($this->config->all() as $key => $value) {$res[$key] = $value['title'];}//dump($res);return $res;}public function findAdminQb($type): QueryBuilder{$cfg = $this->config->get($type);return $this->em->getRepository($cfg->getClass())->{$cfg->getAdminListRepositoryMethod()}();}}