Export: add a "filter activity by creator job" filter

This commit is contained in:
2023-11-07 16:06:22 +01:00
parent abebb79e8b
commit 83fe3ec3fc
7 changed files with 225 additions and 4 deletions

View File

@@ -12,14 +12,15 @@ declare(strict_types=1);
namespace Chill\MainBundle\Repository;
use Chill\MainBundle\Entity\UserJob;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
class UserJobRepository implements UserJobRepositoryInterface
readonly class UserJobRepository implements UserJobRepositoryInterface
{
private readonly EntityRepository $repository;
private EntityRepository $repository;
public function __construct(EntityManagerInterface $em)
public function __construct(EntityManagerInterface $em, private TranslatableStringHelperInterface $translatableStringHelper)
{
$this->repository = $em->getRepository(UserJob::class);
}
@@ -42,6 +43,15 @@ class UserJobRepository implements UserJobRepositoryInterface
return $this->repository->findBy(['active' => true]);
}
public function findAllOrderedByName(): array
{
$jobs = $this->findAll();
usort($jobs, fn (UserJob $a, UserJob $b) => $this->translatableStringHelper->localize($a->getLabel()) <=> $this->translatableStringHelper->localize($b->getLabel()));
return $jobs;
}
/**
* @param mixed|null $limit
* @param mixed|null $offset

View File

@@ -28,6 +28,13 @@ interface UserJobRepositoryInterface extends ObjectRepository
*/
public function findAllActive(): array;
/**
* a list of UserJob ordered by name.
*
* @return array<UserJob>
*/
public function findAllOrderedByName(): array;
/**
* @param mixed|null $limit
* @param mixed|null $offset