diff --git a/src/Bundle/ChillMainBundle/Repository/UserRepository.php b/src/Bundle/ChillMainBundle/Repository/UserRepository.php index 0616878ff..fc3a6e187 100644 --- a/src/Bundle/ChillMainBundle/Repository/UserRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/UserRepository.php @@ -51,11 +51,6 @@ final class UserRepository implements ObjectRepository return (int) $qb->getQuery()->getSingleScalarResult(); } - public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder - { - return $this->repository->createQueryBuilder($alias, $indexBy); - } - public function find($id, $lockMode = null, $lockVersion = null): ?User { return $this->repository->find($id, $lockMode, $lockVersion); diff --git a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php index 04e38da13..24de2d7db 100644 --- a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php @@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Controller; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Pagination\PaginatorFactory; use Chill\MainBundle\Repository\UserRepository; +use Chill\MainBundle\Templating\Entity\UserRender; use Chill\PersonBundle\Repository\AccompanyingPeriodACLAwareRepository; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; @@ -39,9 +40,11 @@ class ReassignAccompanyingPeriodController extends AbstractController private Security $security; + private UserRender $userRender; + private UserRepository $userRepository; - public function __construct(AccompanyingPeriodACLAwareRepository $accompanyingPeriodACLAwareRepository, UserRepository $userRepository, EngineInterface $engine, FormFactoryInterface $formFactory, PaginatorFactory $paginatorFactory, Security $security) + public function __construct(AccompanyingPeriodACLAwareRepository $accompanyingPeriodACLAwareRepository, UserRepository $userRepository, EngineInterface $engine, FormFactoryInterface $formFactory, PaginatorFactory $paginatorFactory, Security $security, UserRender $userRender) { $this->accompanyingPeriodACLAwareRepository = $accompanyingPeriodACLAwareRepository; $this->engine = $engine; @@ -49,6 +52,7 @@ class ReassignAccompanyingPeriodController extends AbstractController $this->paginatorFactory = $paginatorFactory; $this->security = $security; $this->userRepository = $userRepository; + $this->userRender = $userRender; } /** @@ -86,22 +90,18 @@ class ReassignAccompanyingPeriodController extends AbstractController private function buildFilterForm(): FormInterface { - $builder = $this->formFactory->createBuilder(FormType::class, [ + $data = [ + 'user' => null, + ]; + $builder = $this->formFactory->createBuilder(FormType::class, $data, [ 'method' => 'get', 'csrf_protection' => false, ]); $builder ->add('user', EntityType::class, [ 'class' => User::class, - 'query_builder' => function () { - $qb = $this->userRepository->createQueryBuilder('u'); - - $qb->where('u.enabled = true') - ->orderBy('u.username', 'ASC'); - - return $qb; - }, - 'choice_label' => static function (User $u) { - return $u->getUsername(); + 'choices' => $this->userRepository->findByActive(['username' => 'ASC']), + 'choice_label' => function (User $u) { + return $this->userRender->renderString($u, []); }, 'multiple' => false, 'label' => 'User', diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig index d7e11f6ee..55b932751 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/reassign_list.html.twig @@ -42,8 +42,8 @@