mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
fixes for reasign list
* use existing method in UserRepository and use a method instead of building a query outside of the repository; * use renderString to render users * fix building of filter form (add $data). This make the use of the method "get" instead of post
This commit is contained in:
@@ -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',
|
||||
|
Reference in New Issue
Block a user