mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
Improve label for aliases in "Filter by Activity" and use of new-style
EntityRepository for ActivityType * [activity][export] Feature: improve label for aliases in "Filter by activity type" * [activity][export] DX/Feature: use of an `ActivityTypeRepositoryInterface` instead of the old-style EntityRepository
This commit is contained in:
@@ -13,18 +13,58 @@ namespace Chill\ActivityBundle\Repository;
|
||||
|
||||
use Chill\ActivityBundle\Entity\ActivityType;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use UnexpectedValueException;
|
||||
|
||||
/**
|
||||
* @method ActivityType|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method ActivityType|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method ActivityType[] findAll()
|
||||
* @method ActivityType[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class ActivityTypeRepository extends ServiceEntityRepository
|
||||
final class ActivityTypeRepository implements ActivityTypeRepositoryInterface
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
private EntityRepository $repository;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
{
|
||||
parent::__construct($registry, ActivityType::class);
|
||||
$this->repository = $em->getRepository(ActivityType::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|ActivityType[]
|
||||
*/
|
||||
public function findAllActive(): array
|
||||
{
|
||||
return $this->findBy(['active' => true]);
|
||||
}
|
||||
|
||||
public function find($id): ?ActivityType
|
||||
{
|
||||
return $this->repository->find($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|ActivityType[]
|
||||
*/
|
||||
public function findAll(): array
|
||||
{
|
||||
return $this->repository->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|ActivityType[]
|
||||
*/
|
||||
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): ?ActivityType
|
||||
{
|
||||
return $this->repository->findOneBy($criteria);
|
||||
}
|
||||
|
||||
public function getClassName(): string
|
||||
{
|
||||
return ActivityType::class;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\ActivityBundle\Repository;
|
||||
|
||||
use Chill\ActivityBundle\Entity\ActivityType;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
|
||||
interface ActivityTypeRepositoryInterface extends ObjectRepository
|
||||
{
|
||||
/**
|
||||
* @return array|ActivityType[]
|
||||
*/
|
||||
public function findAllActive(): array;
|
||||
|
||||
}
|
Reference in New Issue
Block a user