mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
Feature: [admin][ActivityReason] improve administration for activity reason
* list alphabetically; * show "active" in index
This commit is contained in:
@@ -14,17 +14,38 @@ namespace Chill\ActivityBundle\Repository;
|
||||
use Chill\ActivityBundle\Entity\ActivityReason;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
|
||||
/**
|
||||
* @method ActivityReason|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method ActivityReason|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method ActivityReason[] findAll()
|
||||
* @method ActivityReason[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class ActivityReasonRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
private RequestStack $requestStack;
|
||||
|
||||
public function __construct(
|
||||
ManagerRegistry $registry,
|
||||
RequestStack $requestStack
|
||||
) {
|
||||
parent::__construct($registry, ActivityReason::class);
|
||||
|
||||
$this->requestStack = $requestStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ActivityReason[]
|
||||
*/
|
||||
public function findAll(): array
|
||||
{
|
||||
$qb = $this->createQueryBuilder('ar');
|
||||
$qb->select(['ar'])
|
||||
->leftJoin('ar.category', 'category')
|
||||
->addOrderBy('JSON_EXTRACT(category.name, :lang)')
|
||||
->addOrderBy('JSON_EXTRACT(ar.name, :lang)')
|
||||
->setParameter('lang', $this->requestStack->getCurrentRequest()->getLocale() ?? 'fr');
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user