vendor/dachcom-digital/formbuilder/src/FormBuilderBundle/Repository/FormDefinitionRepository.php line 14

Open in your IDE?
  1. <?php
  2. namespace FormBuilderBundle\Repository;
  3. use Doctrine\ORM\EntityManagerInterface;
  4. use Doctrine\ORM\EntityRepository;
  5. use FormBuilderBundle\Model\FormDefinition;
  6. use FormBuilderBundle\Model\FormDefinitionInterface;
  7. class FormDefinitionRepository implements FormDefinitionRepositoryInterface
  8. {
  9.     protected EntityRepository $repository;
  10.     public function __construct(EntityManagerInterface $entityManager)
  11.     {
  12.         $this->repository $entityManager->getRepository(FormDefinition::class);
  13.     }
  14.     public function findById($id): ?FormDefinitionInterface
  15.     {
  16.         if ($id 1) {
  17.             return null;
  18.         }
  19.         return $this->repository->find($id);
  20.     }
  21.     public function findByName(string $name): ?FormDefinitionInterface
  22.     {
  23.         if (empty($name)) {
  24.             return null;
  25.         }
  26.         return $this->repository->findOneBy(['name' => $name]);
  27.     }
  28.     public function findNameById($id): ?string
  29.     {
  30.         $form $this->findById($id);
  31.         if (!$form instanceof FormDefinitionInterface) {
  32.             return null;
  33.         }
  34.         return $form->getName();
  35.     }
  36.     public function findIdByName(string $name): ?int
  37.     {
  38.         $form $this->findByName($name);
  39.         if (!$form instanceof FormDefinitionInterface) {
  40.             return null;
  41.         }
  42.         return $form->getId();
  43.     }
  44.     public function findAll(): array
  45.     {
  46.         return  $this->repository->findAll();
  47.     }
  48. }