From e9d485f814169f45c8f60833074167f8dce87f21 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 4 Oct 2021 16:09:40 +0200 Subject: [PATCH] fix error when displaying list of Person tasks. --- .../Controller/SingleTaskController.php | 53 +++++++++---------- .../config/services/controller.yaml | 10 +--- 2 files changed, 27 insertions(+), 36 deletions(-) diff --git a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php index 71301dd40..07a85b656 100644 --- a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php +++ b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php @@ -2,8 +2,6 @@ namespace Chill\TaskBundle\Controller; -use Chill\MainBundle\Entity\Center; -use Chill\MainBundle\Entity\Scope; use Chill\PersonBundle\Privacy\PrivacyEvent; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; @@ -21,20 +19,17 @@ use Symfony\Component\Security\Core\Role\Role; use Chill\MainBundle\Pagination\PaginatorFactory; use Chill\TaskBundle\Repository\SingleTaskRepository; use Chill\MainBundle\Entity\User; -use Chill\PersonBundle\Security\Authorization\PersonVoter; -use Chill\PersonBundle\Repository\PersonRepository; -use Chill\TaskBundle\Event\TaskEvent; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Chill\TaskBundle\Event\UI\UIEvent; use Chill\MainBundle\Repository\CenterRepository; use Chill\MainBundle\Repository\ScopeRepository; use Chill\MainBundle\Repository\UserRepository; +use Chill\PersonBundle\Security\Authorization\PersonVoter; +use Chill\TaskBundle\Event\TaskEvent; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Chill\TaskBundle\Event\UI\UIEvent; use Chill\MainBundle\Timeline\TimelineBuilder; -use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Repository\AccompanyingPeriodRepository; +use Chill\PersonBundle\Repository\PersonRepository; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; -use Doctrine\ORM\EntityManagerInterface; -use Doctrine\ORM\EntityRepository; use Symfony\Contracts\Translation\TranslatorInterface as TranslationTranslatorInterface; /** @@ -50,17 +45,17 @@ class SingleTaskController extends AbstractController protected LoggerInterface $logger; - protected EntityRepository $personRepository; + protected PersonRepository $personRepository; - protected EntityRepository $courseRepository; + protected AccompanyingPeriodRepository $courseRepository; + + protected UserRepository $userRepository; + + protected CenterRepository $centerRepository; + + protected ScopeRepository $scopeRepository; protected SingleTaskRepository $taskRepository; - - protected EntityRepository $userRepository; - - protected EntityRepository $centerRepository; - - protected EntityRepository $scopeRepository; /** * SingleTaskController constructor. @@ -71,17 +66,22 @@ class SingleTaskController extends AbstractController EventDispatcherInterface $eventDispatcher, TimelineBuilder $timelineBuilder, LoggerInterface $logger, - EntityManagerInterface $em + SingleTaskRepository $singleTaskRepository, + PersonRepository $personRepository, + AccompanyingPeriodRepository $courseRepository, + UserRepository $userRepository, + CenterRepository $centerRepository, + ScopeRepository $scopeRepository ) { $this->eventDispatcher = $eventDispatcher; $this->timelineBuilder = $timelineBuilder; $this->logger = $logger; - $this->personRepository = $em->getRepository(Person::class); - $this->courseRepository = $em->getRepository(AccompanyingPeriod::class); - $this->taskRepository = $em->getRepository(SingleTask::class); - $this->userRepository = $em->getRepository(User::class); - $this->centerRepository = $em->getRepository(Center::class); - $this->scopeRepository = $em->getRepository(Scope::class); + $this->taskRepository = $singleTaskRepository; + $this->scopeRepository = $scopeRepository; + $this->centerRepository = $centerRepository; + $this->userRepository = $userRepository; + $this->personRepository = $personRepository; + $this->courseRepository = $courseRepository; } @@ -533,9 +533,6 @@ class SingleTaskController extends AbstractController public function listAction( PaginatorFactory $paginatorFactory, // SingleTaskRepository $taskRepository, - // PersonRepository $personRepository, - // AccompanyingPeriodRepository $courseRepository, - // CenterRepository $centerRepository, FormFactoryInterface $formFactory, Request $request ) { diff --git a/src/Bundle/ChillTaskBundle/config/services/controller.yaml b/src/Bundle/ChillTaskBundle/config/services/controller.yaml index 80b8c0b08..d8f4bf7ca 100644 --- a/src/Bundle/ChillTaskBundle/config/services/controller.yaml +++ b/src/Bundle/ChillTaskBundle/config/services/controller.yaml @@ -1,12 +1,6 @@ services: Chill\TaskBundle\Controller\: resource: "../../Controller" - tags: ["controller.service_arguments"] - - Chill\TaskBundle\Controller\SingleTaskController: - arguments: - $eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface' - $timelineBuilder: "@chill_main.timeline_builder" - $logger: "@chill.main.logger" - $em: "@doctrine.orm.default_entity_manager" + autowire: true + autoconfigure: true tags: ["controller.service_arguments"]