mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-22 15:43:51 +00:00
order scopes alphabetically
This commit is contained in:
@@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
namespace Chill\MainBundle\Repository;
|
||||
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
@@ -20,7 +21,7 @@ final class ScopeRepository implements ScopeRepositoryInterface
|
||||
{
|
||||
private readonly EntityRepository $repository;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
public function __construct(EntityManagerInterface $entityManager, private readonly TranslatableStringHelperInterface $translatableStringHelper)
|
||||
{
|
||||
$this->repository = $entityManager->getRepository(Scope::class);
|
||||
}
|
||||
@@ -45,11 +46,11 @@ final class ScopeRepository implements ScopeRepositoryInterface
|
||||
|
||||
public function findAllActive(): array
|
||||
{
|
||||
$qb = $this->repository->createQueryBuilder('s');
|
||||
$scopes = $this->repository->findBy(['active' => true]);
|
||||
|
||||
$qb->where('s.active = \'TRUE\'');
|
||||
usort($scopes, fn (Scope $a, Scope $b) => $this->translatableStringHelper->localize($a->getName()) <=> $this->translatableStringHelper->localize($b->getName()));
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
return $scopes;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user