DXFeature: ClosingMotiveRepository implements correct interace

This commit is contained in:
Julien Fastré 2022-09-22 14:01:30 +02:00
parent 4631f04da6
commit 4fe4f6a877
3 changed files with 49 additions and 3 deletions

View File

@ -16,18 +16,19 @@ use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive;
use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Repository\AccompanyingPeriod\ClosingMotiveRepository;
use Chill\PersonBundle\Repository\AccompanyingPeriod\ClosingMotiveRepositoryInterface;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
class ClosingMotiveAggregator implements AggregatorInterface
{
private EntityManagerInterface $em;
private ClosingMotiveRepositoryInterface $motiveRepository;
private TranslatableStringHelper $translatableStringHelper;
public function __construct(
ClosingMotiveRepository $motiveRepository,
ClosingMotiveRepositoryInterface $motiveRepository,
TranslatableStringHelper $translatableStringHelper
) {
$this->motiveRepository = $motiveRepository;

View File

@ -15,8 +15,9 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query\ResultSetMappingBuilder;
use UnexpectedValueException;
final class ClosingMotiveRepository
final class ClosingMotiveRepository implements ClosingMotiveRepositoryInterface
{
private EntityManagerInterface $entityManager;
@ -54,4 +55,35 @@ final class ClosingMotiveRepository
->createNativeQuery($sql, $rsm)
->getResult();
}
public function find($id): ?ClosingMotive
{
return $this->repository->find($id);
}
/**
* @return array|ClosingMotive[]
*/
public function findAll(): array
{
return $this->repository->findAll();
}
/**
* @return array|ClosingMotive[]
*/
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array
{
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
}
public function findOneBy(array $criteria): ?ClosingMotive
{
return $this->findOneBy($criteria);
}
public function getClassName(): string
{
return ClosingMotive::class;
}
}

View File

@ -0,0 +1,13 @@
<?php
namespace Chill\PersonBundle\Repository\AccompanyingPeriod;
use Doctrine\Persistence\ObjectRepository;
interface ClosingMotiveRepositoryInterface extends ObjectRepository
{
/**
* @return mixed
*/
public function getActiveClosingMotive(bool $onlyLeaf = true);
}