mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-10-31 09:18:24 +00:00 
			
		
		
		
	apply rules rector
This commit is contained in:
		| @@ -77,10 +77,8 @@ final class ActivityController extends AbstractController | ||||
|  | ||||
|     /** | ||||
|      * Deletes a Activity entity. | ||||
|      * | ||||
|      * @param mixed $id | ||||
|      */ | ||||
|     public function deleteAction(Request $request, $id) | ||||
|     public function deleteAction(Request $request, mixed $id) | ||||
|     { | ||||
|         $view = null; | ||||
|  | ||||
| @@ -679,8 +677,8 @@ final class ActivityController extends AbstractController | ||||
|                 throw $this->createNotFoundException('Accompanying Period not found'); | ||||
|             } | ||||
|  | ||||
|             // TODO Add permission | ||||
|             // $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); | ||||
|         // TODO Add permission | ||||
|         // $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); | ||||
|         } else { | ||||
|             throw $this->createNotFoundException('Person or Accompanying Period not found'); | ||||
|         } | ||||
|   | ||||
| @@ -94,17 +94,9 @@ class DateAggregator implements AggregatorInterface | ||||
|                 return ''; | ||||
|             } | ||||
|  | ||||
|             switch ($data['frequency']) { | ||||
|                 case 'month': | ||||
|                 case 'week': | ||||
|                     //return $this->translator->trans('for week') .' '. $value ; | ||||
|  | ||||
|                 case 'year': | ||||
|                     //return $this->translator->trans('in year') .' '. $value ; | ||||
|  | ||||
|                 default: | ||||
|                     return $value; | ||||
|             } | ||||
|             return match ($data['frequency']) { | ||||
|                 default => $value, | ||||
|             }; | ||||
|         }; | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -23,22 +23,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; | ||||
|  */ | ||||
| final class PersonMenuBuilder implements LocalMenuBuilderInterface | ||||
| { | ||||
|     /** | ||||
|      * @var AuthorizationCheckerInterface | ||||
|      */ | ||||
|     private $authorizationChecker; | ||||
|  | ||||
|     /** | ||||
|      * @var TranslatorInterface | ||||
|      */ | ||||
|     private $translator; | ||||
|  | ||||
|     public function __construct( | ||||
|         AuthorizationCheckerInterface $authorizationChecker, | ||||
|         TranslatorInterface $translator | ||||
|     ) { | ||||
|         $this->translator = $translator; | ||||
|         $this->authorizationChecker = $authorizationChecker; | ||||
|     public function __construct(private AuthorizationCheckerInterface $authorizationChecker, private TranslatorInterface $translator) | ||||
|     { | ||||
|     } | ||||
|  | ||||
|     public function buildMenu($menuId, MenuItem $menu, array $parameters) | ||||
|   | ||||
| @@ -42,48 +42,17 @@ class ActivityContext implements | ||||
|     DocGeneratorContextWithAdminFormInterface, | ||||
|     DocGeneratorContextWithPublicFormInterface | ||||
| { | ||||
|     private BaseContextData $baseContextData; | ||||
|  | ||||
|     private DocumentCategoryRepository $documentCategoryRepository; | ||||
|  | ||||
|     private EntityManagerInterface $em; | ||||
|  | ||||
|     private NormalizerInterface $normalizer; | ||||
|  | ||||
|     private PersonRenderInterface $personRender; | ||||
|  | ||||
|     private PersonRepository $personRepository; | ||||
|  | ||||
|     private TranslatableStringHelperInterface $translatableStringHelper; | ||||
|  | ||||
|     private TranslatorInterface $translator; | ||||
|  | ||||
|     private ThirdPartyRender $thirdPartyRender; | ||||
|  | ||||
|     private ThirdPartyRepository $thirdPartyRepository; | ||||
|  | ||||
|     public function __construct( | ||||
|         DocumentCategoryRepository $documentCategoryRepository, | ||||
|         NormalizerInterface $normalizer, | ||||
|         TranslatableStringHelperInterface $translatableStringHelper, | ||||
|         EntityManagerInterface $em, | ||||
|         PersonRenderInterface $personRender, | ||||
|         PersonRepository $personRepository, | ||||
|         TranslatorInterface $translator, | ||||
|         BaseContextData $baseContextData, | ||||
|         ThirdPartyRender $thirdPartyRender, | ||||
|         ThirdPartyRepository $thirdPartyRepository | ||||
|         private NormalizerInterface $normalizer, | ||||
|         private TranslatableStringHelperInterface $translatableStringHelper, | ||||
|         private EntityManagerInterface $em, | ||||
|         private PersonRenderInterface $personRender, | ||||
|         private PersonRepository $personRepository, | ||||
|         private TranslatorInterface $translator, | ||||
|         private BaseContextData $baseContextData, | ||||
|         private ThirdPartyRender $thirdPartyRender, | ||||
|         private ThirdPartyRepository $thirdPartyRepository | ||||
|     ) { | ||||
|         $this->documentCategoryRepository = $documentCategoryRepository; | ||||
|         $this->normalizer = $normalizer; | ||||
|         $this->translatableStringHelper = $translatableStringHelper; | ||||
|         $this->em = $em; | ||||
|         $this->personRender = $personRender; | ||||
|         $this->personRepository = $personRepository; | ||||
|         $this->translator = $translator; | ||||
|         $this->baseContextData = $baseContextData; | ||||
|         $this->thirdPartyRender = $thirdPartyRender; | ||||
|         $this->thirdPartyRepository = $thirdPartyRepository; | ||||
|     } | ||||
|  | ||||
|     public function adminFormReverseTransform(array $data): array | ||||
|   | ||||
| @@ -21,14 +21,8 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod; | ||||
|  | ||||
| final class AccompanyingPeriodActivityGenericDocRenderer implements GenericDocRendererInterface | ||||
| { | ||||
|     private StoredObjectRepository $objectRepository; | ||||
|  | ||||
|     private ActivityRepository $activityRepository; | ||||
|  | ||||
|     public function __construct(StoredObjectRepository $storedObjectRepository, ActivityRepository $activityRepository) | ||||
|     public function __construct(private StoredObjectRepository $objectRepository, private ActivityRepository $activityRepository) | ||||
|     { | ||||
|         $this->objectRepository = $storedObjectRepository; | ||||
|         $this->activityRepository = $activityRepository; | ||||
|     } | ||||
|  | ||||
|     public function supports(GenericDocDTO $genericDocDTO, $options = []): bool | ||||
|   | ||||
| @@ -19,11 +19,8 @@ use Chill\DocStoreBundle\GenericDoc\Twig\GenericDocRendererInterface; | ||||
|  | ||||
| final class AccompanyingPeriodCalendarGenericDocRenderer implements GenericDocRendererInterface | ||||
| { | ||||
|     private CalendarDocRepository $repository; | ||||
|  | ||||
|     public function __construct(CalendarDocRepository $calendarDocRepository) | ||||
|     public function __construct(private CalendarDocRepository $repository) | ||||
|     { | ||||
|         $this->repository = $calendarDocRepository; | ||||
|     } | ||||
|  | ||||
|     public function supports(GenericDocDTO $genericDocDTO, $options = []): bool | ||||
|   | ||||
| @@ -33,23 +33,14 @@ use Symfony\Contracts\Translation\TranslatorInterface; | ||||
|  */ | ||||
| class DocumentAccompanyingCourseController extends AbstractController | ||||
| { | ||||
|     protected AuthorizationHelper $authorizationHelper; | ||||
|  | ||||
|     protected EventDispatcherInterface $eventDispatcher; | ||||
|  | ||||
|     protected TranslatorInterface $translator; | ||||
|  | ||||
|     /** | ||||
|      * DocumentAccompanyingCourseController constructor. | ||||
|      */ | ||||
|     public function __construct( | ||||
|         TranslatorInterface $translator, | ||||
|         EventDispatcherInterface $eventDispatcher, | ||||
|         AuthorizationHelper $authorizationHelper, | ||||
|         protected TranslatorInterface $translator, | ||||
|         protected EventDispatcherInterface $eventDispatcher, | ||||
|         protected AuthorizationHelper $authorizationHelper | ||||
|     ) { | ||||
|         $this->translator = $translator; | ||||
|         $this->eventDispatcher = $eventDispatcher; | ||||
|         $this->authorizationHelper = $authorizationHelper; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|   | ||||
| @@ -39,23 +39,14 @@ use Symfony\Contracts\Translation\TranslatorInterface; | ||||
|  */ | ||||
| class DocumentPersonController extends AbstractController | ||||
| { | ||||
|     protected AuthorizationHelper $authorizationHelper; | ||||
|  | ||||
|     protected EventDispatcherInterface $eventDispatcher; | ||||
|  | ||||
|     protected TranslatorInterface $translator; | ||||
|  | ||||
|     /** | ||||
|      * DocumentPersonController constructor. | ||||
|      */ | ||||
|     public function __construct( | ||||
|         TranslatorInterface $translator, | ||||
|         EventDispatcherInterface $eventDispatcher, | ||||
|         AuthorizationHelper $authorizationHelper, | ||||
|         protected TranslatorInterface $translator, | ||||
|         protected EventDispatcherInterface $eventDispatcher, | ||||
|         protected AuthorizationHelper $authorizationHelper | ||||
|     ) { | ||||
|         $this->translator = $translator; | ||||
|         $this->eventDispatcher = $eventDispatcher; | ||||
|         $this->authorizationHelper = $authorizationHelper; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|   | ||||
| @@ -35,8 +35,6 @@ final readonly class GenericDocForAccompanyingPeriodController | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param AccompanyingPeriod $accompanyingPeriod | ||||
|      * @return Response | ||||
|      * @throws \Doctrine\DBAL\Exception | ||||
|      * | ||||
|      * @Route("/{_locale}/doc-store/generic-doc/by-period/{id}/index", name="chill_docstore_generic-doc_by-period_index") | ||||
|   | ||||
| @@ -25,7 +25,6 @@ final readonly class FetchQueryToSqlBuilder | ||||
|     SQL; | ||||
|  | ||||
|     /** | ||||
|      * @param FetchQueryInterface $query | ||||
|      * @return array{sql: string, params: list<mixed>, types: list<Types::*>} | ||||
|      */ | ||||
|     public function toSql(FetchQueryInterface $query): array | ||||
|   | ||||
| @@ -41,40 +41,13 @@ class EventSearch extends AbstractSearch | ||||
| { | ||||
|     public const NAME = 'event_regular'; | ||||
|  | ||||
|     private $security; | ||||
|  | ||||
|     /** | ||||
|      * @var EventRepository | ||||
|      */ | ||||
|     private $er; | ||||
|  | ||||
|     /** | ||||
|      * @var AuthorizationHelper | ||||
|      */ | ||||
|     private $authorizationHelper; | ||||
|  | ||||
|     /** | ||||
|      * @var PaginatorFactory | ||||
|      */ | ||||
|     private $paginationFactory; | ||||
|  | ||||
|     /** | ||||
|      * @var TemplatingEngine | ||||
|      */ | ||||
|     private $templating; | ||||
|  | ||||
|     public function __construct( | ||||
|         Security $security, | ||||
|         EventRepository $eventRepository, | ||||
|         AuthorizationHelper $authorizationHelper, | ||||
|         TemplatingEngine $templating, | ||||
|         PaginatorFactory $paginatorFactory | ||||
|         private Security $security, | ||||
|         private EventRepository $er, | ||||
|         private AuthorizationHelper $authorizationHelper, | ||||
|         private TemplatingEngine $templating, | ||||
|         private PaginatorFactory $paginationFactory | ||||
|     ) { | ||||
|         $this->security = $security; | ||||
|         $this->er = $eventRepository; | ||||
|         $this->authorizationHelper = $authorizationHelper; | ||||
|         $this->templating = $templating; | ||||
|         $this->paginationFactory = $paginatorFactory; | ||||
|     } | ||||
|  | ||||
|     public function getOrder() | ||||
|   | ||||
| @@ -52,57 +52,18 @@ use function unserialize; | ||||
|  */ | ||||
| class ExportController extends AbstractController | ||||
| { | ||||
|     private EntityManagerInterface $entityManager; | ||||
|  | ||||
|     /** | ||||
|      * @var ExportManager | ||||
|      */ | ||||
|     private $exportManager; | ||||
|  | ||||
|     /** | ||||
|      * @var FormFactoryInterface | ||||
|      */ | ||||
|     private $formFactory; | ||||
|  | ||||
|     /** | ||||
|      * @var LoggerInterface | ||||
|      */ | ||||
|     private $logger; | ||||
|  | ||||
|     /** | ||||
|      * @var ChillRedis | ||||
|      */ | ||||
|     private $redis; | ||||
|  | ||||
|     /** | ||||
|      * @var SessionInterface | ||||
|      */ | ||||
|     private $session; | ||||
|  | ||||
|     /** | ||||
|      * @var TranslatorInterface | ||||
|      */ | ||||
|     private $translator; | ||||
|  | ||||
|     public function __construct( | ||||
|         ChillRedis $chillRedis, | ||||
|         ExportManager $exportManager, | ||||
|         FormFactoryInterface $formFactory, | ||||
|         LoggerInterface $logger, | ||||
|         SessionInterface $session, | ||||
|         TranslatorInterface $translator, | ||||
|         EntityManagerInterface $entityManager, | ||||
|         private ChillRedis $redis, | ||||
|         private ExportManager $exportManager, | ||||
|         private FormFactoryInterface $formFactory, | ||||
|         private LoggerInterface $logger, | ||||
|         private SessionInterface $session, | ||||
|         private TranslatorInterface $translator, | ||||
|         private EntityManagerInterface $entityManager, | ||||
|         private readonly ExportFormHelper $exportFormHelper, | ||||
|         private readonly SavedExportRepositoryInterface $savedExportRepository, | ||||
|         private readonly Security $security, | ||||
|         private readonly Security $security | ||||
|     ) { | ||||
|         $this->entityManager = $entityManager; | ||||
|         $this->redis = $chillRedis; | ||||
|         $this->exportManager = $exportManager; | ||||
|         $this->formFactory = $formFactory; | ||||
|         $this->logger = $logger; | ||||
|         $this->session = $session; | ||||
|         $this->translator = $translator; | ||||
|     } | ||||
|  | ||||
|     public function downloadResultAction(Request $request, $alias) | ||||
| @@ -228,22 +189,13 @@ class ExportController extends AbstractController | ||||
|  | ||||
|         $step = $request->query->getAlpha('step', 'centers'); | ||||
|  | ||||
|         switch ($step) { | ||||
|             case 'centers': | ||||
|                 return $this->selectCentersStep($request, $export, $alias, $savedExport); | ||||
|  | ||||
|             case 'export': | ||||
|                 return $this->exportFormStep($request, $export, $alias, $savedExport); | ||||
|  | ||||
|             case 'formatter': | ||||
|                 return $this->formatterFormStep($request, $export, $alias, $savedExport); | ||||
|  | ||||
|             case 'generate': | ||||
|                 return $this->forwardToGenerate($request, $export, $alias, $savedExport); | ||||
|  | ||||
|             default: | ||||
|                 throw $this->createNotFoundException("The given step '{$step}' is invalid"); | ||||
|         } | ||||
|         return match ($step) { | ||||
|             'centers' => $this->selectCentersStep($request, $export, $alias, $savedExport), | ||||
|             'export' => $this->exportFormStep($request, $export, $alias, $savedExport), | ||||
|             'formatter' => $this->formatterFormStep($request, $export, $alias, $savedExport), | ||||
|             'generate' => $this->forwardToGenerate($request, $export, $alias, $savedExport), | ||||
|             default => throw $this->createNotFoundException("The given step '{$step}' is invalid"), | ||||
|         }; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
| @@ -317,7 +269,7 @@ class ExportController extends AbstractController | ||||
|     { | ||||
|         /** @var \Chill\MainBundle\Export\ExportManager $exportManager */ | ||||
|         $exportManager = $this->exportManager; | ||||
|         $isGenerate = strpos($step, 'generate_') === 0; | ||||
|         $isGenerate = str_starts_with($step, 'generate_'); | ||||
|  | ||||
|         $options = match ($step) { | ||||
|             'export', 'generate_export' => [ | ||||
| @@ -493,7 +445,7 @@ class ExportController extends AbstractController | ||||
|      * | ||||
|      * @return \Symfony\Component\HttpFoundation\RedirectResponse | ||||
|      */ | ||||
|     private function forwardToGenerate(Request $request, $export, $alias, ?SavedExport $savedExport) | ||||
|     private function forwardToGenerate(Request $request, \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export, $alias, ?SavedExport $savedExport) | ||||
|     { | ||||
|         $dataCenters = $this->session->get('centers_step_raw', null); | ||||
|         $dataFormatter = $this->session->get('formatter_step_raw', null); | ||||
| @@ -560,12 +512,10 @@ class ExportController extends AbstractController | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export | ||||
|      * @param string $alias | ||||
|      * | ||||
|      * @return Response | ||||
|      */ | ||||
|     private function selectCentersStep(Request $request, $export, $alias, ?SavedExport $savedExport = null) | ||||
|     private function selectCentersStep(Request $request, \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export, $alias, ?SavedExport $savedExport = null) | ||||
|     { | ||||
|         /** @var \Chill\MainBundle\Export\ExportManager $exportManager */ | ||||
|         $exportManager = $this->exportManager; | ||||
| @@ -647,7 +597,7 @@ class ExportController extends AbstractController | ||||
|      * | ||||
|      * @return string the next/current step | ||||
|      */ | ||||
|     private function getNextStep($step, $export, $reverse = false) | ||||
|     private function getNextStep($step, \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export, $reverse = false) | ||||
|     { | ||||
|         switch ($step) { | ||||
|             case 'centers': | ||||
|   | ||||
| @@ -92,11 +92,9 @@ final readonly class UserExportController | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @return StreamedResponse | ||||
|      * @throws \League\Csv\CannotInsertRecord | ||||
|      * @throws \League\Csv\Exception | ||||
|      * @throws \League\Csv\UnavailableStream | ||||
|      * | ||||
|      * @Route("/{_locale}/admin/main/users/export/permissions.{_format}", requirements={"_format": "csv"}, name="chill_main_users_export_permissions") | ||||
|      */ | ||||
|     public function userPermissionsList(string $_format = 'csv'): StreamedResponse | ||||
|   | ||||
| @@ -39,7 +39,7 @@ use function array_key_exists; | ||||
|  * If a tasks is "forced", there is no test about eligibility of the task (the `canRun` method is not called), | ||||
|  * and the last task execution is not recorded. | ||||
|  */ | ||||
| class CronManager implements CronManagerInterface | ||||
| final readonly class CronManager implements CronManagerInterface | ||||
| { | ||||
|     private const LOG_PREFIX = '[cron manager] '; | ||||
|  | ||||
| @@ -49,30 +49,15 @@ class CronManager implements CronManagerInterface | ||||
|  | ||||
|     private const UPDATE_LAST_EXECUTION_DATA = 'UPDATE ' . CronJobExecution::class . ' cr SET cr.lastExecutionData = :data WHERE cr.key = :key'; | ||||
|  | ||||
|     private CronJobExecutionRepositoryInterface $cronJobExecutionRepository; | ||||
|  | ||||
|     private EntityManagerInterface $entityManager; | ||||
|  | ||||
|     /** | ||||
|      * @var iterable<CronJobInterface> | ||||
|      */ | ||||
|     private iterable $jobs; | ||||
|  | ||||
|     private LoggerInterface $logger; | ||||
|  | ||||
|     /** | ||||
|      * @param CronJobInterface[] $jobs | ||||
|      */ | ||||
|     public function __construct( | ||||
|         CronJobExecutionRepositoryInterface $cronJobExecutionRepository, | ||||
|         EntityManagerInterface $entityManager, | ||||
|         iterable $jobs, | ||||
|         LoggerInterface $logger | ||||
|         private CronJobExecutionRepositoryInterface $cronJobExecutionRepository, | ||||
|         private EntityManagerInterface $entityManager, | ||||
|         private iterable $jobs, | ||||
|         private LoggerInterface $logger | ||||
|     ) { | ||||
|         $this->cronJobExecutionRepository = $cronJobExecutionRepository; | ||||
|         $this->entityManager = $entityManager; | ||||
|         $this->jobs = $jobs; | ||||
|         $this->logger = $logger; | ||||
|     } | ||||
|  | ||||
|     public function run(?string $forceJob = null): void | ||||
| @@ -134,7 +119,7 @@ class CronManager implements CronManagerInterface | ||||
|                     $this->logger->info(sprintf('%sSuccessfully run job', self::LOG_PREFIX), ['job' => $job->getKey()]); | ||||
|  | ||||
|                     return; | ||||
|                 } catch (Exception $e) { | ||||
|                 } catch (Exception) { | ||||
|                     $this->logger->error(sprintf('%sRunning job failed', self::LOG_PREFIX), ['job' => $job->getKey()]); | ||||
|                     $this->entityManager | ||||
|                         ->createQuery(self::UPDATE_AFTER_EXEC) | ||||
|   | ||||
| @@ -24,12 +24,6 @@ class CronJobExecution | ||||
|  | ||||
|     public const SUCCESS = 1; | ||||
|  | ||||
|     /** | ||||
|      * @ORM\Column(type="text", nullable=false) | ||||
|      * @ORM\Id | ||||
|      */ | ||||
|     private string $key; | ||||
|  | ||||
|     /** | ||||
|      * @ORM\Column(type="datetime_immutable", nullable=true, options={"default": null}) | ||||
|      */ | ||||
| @@ -50,9 +44,12 @@ class CronJobExecution | ||||
|      */ | ||||
|     private array $lastExecutionData = []; | ||||
|  | ||||
|     public function __construct(string $key) | ||||
|     { | ||||
|         $this->key = $key; | ||||
|     public function __construct(/** | ||||
|      * @ORM\Column(type="text", nullable=false) | ||||
|      * @ORM\Id | ||||
|      */ | ||||
|         private string $key | ||||
|     ) { | ||||
|         $this->lastStart = new DateTimeImmutable('now'); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -272,10 +272,7 @@ class User implements UserInterface, \Stringable | ||||
|         return ['ROLE_USER']; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @return string|null | ||||
|      */ | ||||
|     public function getSalt() | ||||
|     public function getSalt(): ?string | ||||
|     { | ||||
|         return $this->salt; | ||||
|     } | ||||
|   | ||||
| @@ -43,10 +43,6 @@ class ExportManager | ||||
|      */ | ||||
|     private array $aggregators = []; | ||||
|  | ||||
|     private AuthorizationCheckerInterface $authorizationChecker; | ||||
|  | ||||
|     private AuthorizationHelperInterface $authorizationHelper; | ||||
|  | ||||
|     /** | ||||
|      * Collected Exports, injected by DI. | ||||
|      * | ||||
| @@ -68,17 +64,15 @@ class ExportManager | ||||
|      */ | ||||
|     private array $formatters = []; | ||||
|  | ||||
|     private LoggerInterface $logger; | ||||
|  | ||||
|     /** | ||||
|      * @var \Symfony\Component\Security\Core\User\UserInterface | ||||
|      */ | ||||
|     private $user; | ||||
|  | ||||
|     public function __construct( | ||||
|         LoggerInterface $logger, | ||||
|         AuthorizationCheckerInterface $authorizationChecker, | ||||
|         AuthorizationHelperInterface $authorizationHelper, | ||||
|         private LoggerInterface $logger, | ||||
|         private AuthorizationCheckerInterface $authorizationChecker, | ||||
|         private AuthorizationHelperInterface $authorizationHelper, | ||||
|         TokenStorageInterface $tokenStorage, | ||||
|         iterable $exports, | ||||
|         iterable $aggregators, | ||||
| @@ -86,9 +80,6 @@ class ExportManager | ||||
|         //iterable $formatters, | ||||
|         //iterable $exportElementProvider | ||||
|     ) { | ||||
|         $this->logger = $logger; | ||||
|         $this->authorizationChecker = $authorizationChecker; | ||||
|         $this->authorizationHelper = $authorizationHelper; | ||||
|         $this->user = $tokenStorage->getToken()->getUser(); | ||||
|         $this->exports = iterator_to_array($exports); | ||||
|         $this->aggregators = iterator_to_array($aggregators); | ||||
| @@ -166,7 +157,7 @@ class ExportManager | ||||
|             } elseif ($element instanceof FormatterInterface) { | ||||
|                 $this->addFormatter($element, $alias); | ||||
|             } else { | ||||
|                 throw new LogicException('This element ' . get_class($element) . ' ' | ||||
|                 throw new LogicException('This element ' . $element::class . ' ' | ||||
|                     . 'is not an instance of export element'); | ||||
|             } | ||||
|         } | ||||
| @@ -285,7 +276,6 @@ class ExportManager | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param array $aliases | ||||
|      * @return iterable<string, AggregatorInterface> | ||||
|      */ | ||||
|     public function getAggregators(array $aliases): iterable | ||||
| @@ -352,7 +342,6 @@ class ExportManager | ||||
|     /** | ||||
|      * Get all exports grouped in an array. | ||||
|      * | ||||
|      * @param bool $whereUserIsGranted | ||||
|      * | ||||
|      * @return array<string, array<string, ExportInterface|DirectExportInterface>> where keys are the groups's name and value is an array of exports | ||||
|      */ | ||||
| @@ -372,8 +361,6 @@ class ExportManager | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param string $alias | ||||
|      * | ||||
|      * @throws RuntimeException if the filter is not known | ||||
|      */ | ||||
|     public function getFilter(string $alias): FilterInterface | ||||
| @@ -467,11 +454,9 @@ class ExportManager | ||||
|      * Return true if the current user has access to the ExportElement for every | ||||
|      * center, false if the user hasn't access to element for at least one center. | ||||
|      * | ||||
|      * @param \Chill\MainBundle\Export\ExportElementInterface $element | ||||
|      * @param DirectExportInterface|ExportInterface $export | ||||
|      * | ||||
|      */ | ||||
|     public function isGrantedForElement(ExportElementInterface $element, ?ExportElementInterface $export = null, ?array $centers = null): bool | ||||
|     public function isGrantedForElement(ExportElementInterface $element, \Chill\MainBundle\Export\DirectExportInterface|\Chill\MainBundle\Export\ExportInterface $export = null, ?array $centers = null): bool | ||||
|     { | ||||
|         if ($element instanceof ExportInterface || $element instanceof DirectExportInterface) { | ||||
|             $role = $element->requiredRole(); | ||||
| @@ -504,7 +489,7 @@ class ExportManager | ||||
|                 //debugging | ||||
|                 $this->logger->debug('user has no access to element', [ | ||||
|                     'method' => __METHOD__, | ||||
|                     'type' => get_class($element), | ||||
|                     'type' => $element::class, | ||||
|                     'center' => $center->getName(), | ||||
|                     'role' => $role, | ||||
|                 ]); | ||||
| @@ -574,7 +559,7 @@ class ExportManager | ||||
|     private function handleFilters( | ||||
|         ExportInterface $export, | ||||
|         QueryBuilder $qb, | ||||
|         $data, | ||||
|         mixed $data, | ||||
|         array $centers | ||||
|     ) { | ||||
|         $filters = $this->retrieveUsedFilters($data); | ||||
| @@ -595,11 +580,9 @@ class ExportManager | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param mixed $data | ||||
|      * | ||||
|      * @return iterable<string, AggregatorInterface> | ||||
|      */ | ||||
|     private function retrieveUsedAggregators($data): iterable | ||||
|     private function retrieveUsedAggregators(mixed $data): iterable | ||||
|     { | ||||
|         if (null === $data) { | ||||
|             return []; | ||||
| @@ -613,11 +596,9 @@ class ExportManager | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param mixed $data | ||||
|      * | ||||
|      * @return string[] | ||||
|      */ | ||||
|     private function retrieveUsedAggregatorsType($data) | ||||
|     private function retrieveUsedAggregatorsType(mixed $data) | ||||
|     { | ||||
|         if (null === $data) { | ||||
|             return []; | ||||
| @@ -657,7 +638,7 @@ class ExportManager | ||||
|      * | ||||
|      * @return array an array with types | ||||
|      */ | ||||
|     private function retrieveUsedFiltersType($data) | ||||
|     private function retrieveUsedFiltersType(mixed $data) | ||||
|     { | ||||
|         if (null === $data) { | ||||
|             return []; | ||||
| @@ -681,11 +662,10 @@ class ExportManager | ||||
|     /** | ||||
|      * parse the data to retrieve the used filters and aggregators. | ||||
|      * | ||||
|      * @param mixed $data | ||||
|      * | ||||
|      * @return string[] | ||||
|      */ | ||||
|     private function retrieveUsedModifiers($data) | ||||
|     private function retrieveUsedModifiers(mixed $data) | ||||
|     { | ||||
|         if (null === $data) { | ||||
|             return []; | ||||
|   | ||||
| @@ -34,20 +34,11 @@ final class PickCenterType extends AbstractType | ||||
| { | ||||
|     public const CENTERS_IDENTIFIERS = 'c'; | ||||
|  | ||||
|     private AuthorizationHelperForCurrentUserInterface $authorizationHelper; | ||||
|  | ||||
|     private ExportManager $exportManager; | ||||
|  | ||||
|     private RegroupmentRepository $regroupmentRepository; | ||||
|  | ||||
|     public function __construct( | ||||
|         ExportManager $exportManager, | ||||
|         RegroupmentRepository $regroupmentRepository, | ||||
|         AuthorizationHelperForCurrentUserInterface $authorizationHelper | ||||
|         private ExportManager $exportManager, | ||||
|         private RegroupmentRepository $regroupmentRepository, | ||||
|         private AuthorizationHelperForCurrentUserInterface $authorizationHelper | ||||
|     ) { | ||||
|         $this->exportManager = $exportManager; | ||||
|         $this->authorizationHelper = $authorizationHelper; | ||||
|         $this->regroupmentRepository = $regroupmentRepository; | ||||
|     } | ||||
|  | ||||
|     public function buildForm(FormBuilderInterface $builder, array $options) | ||||
|   | ||||
| @@ -23,8 +23,6 @@ use Doctrine\Persistence\ObjectRepository; | ||||
|  | ||||
| final class NotificationRepository implements ObjectRepository | ||||
| { | ||||
|     private EntityManagerInterface $em; | ||||
|  | ||||
|     private ?Statement $notificationByRelatedEntityAndUserAssociatedStatement = null; | ||||
|  | ||||
|     private EntityRepository $repository; | ||||
| @@ -38,10 +36,9 @@ final class NotificationRepository implements ObjectRepository | ||||
|     SQL; | ||||
|  | ||||
|  | ||||
|     public function __construct(EntityManagerInterface $entityManager) | ||||
|     public function __construct(private EntityManagerInterface $em) | ||||
|     { | ||||
|         $this->em = $entityManager; | ||||
|         $this->repository = $entityManager->getRepository(Notification::class); | ||||
|         $this->repository = $em->getRepository(Notification::class); | ||||
|     } | ||||
|  | ||||
|     public function countAllForAttendee(User $addressee): int | ||||
|   | ||||
| @@ -30,8 +30,7 @@ class PasswordRecoverEvent extends Event | ||||
|         private ?User $user = null, | ||||
|         private $ip = null, | ||||
|         private bool $safelyGenerated = false, | ||||
|     ) | ||||
|     { | ||||
|     ) { | ||||
|     } | ||||
|  | ||||
|     public function getIp() | ||||
|   | ||||
| @@ -28,7 +28,6 @@ final readonly class FilterOrderGetActiveFilterHelper | ||||
|     /** | ||||
|      * Return all the data required to display the active filters | ||||
|      * | ||||
|      * @param FilterOrderHelper $filterOrderHelper | ||||
|      * @return array<array{label: string, value: string, position: string, name: string}> | ||||
|      */ | ||||
|     public function getActiveFilters(FilterOrderHelper $filterOrderHelper): array | ||||
| @@ -65,7 +64,7 @@ final readonly class FilterOrderGetActiveFilterHelper | ||||
|                     $value = $this->propertyAccessor->getValue($selected, $options['choice_label']); | ||||
|                 } else { | ||||
|                     if (!$selected instanceof \Stringable) { | ||||
|                         throw new \UnexpectedValueException(sprintf("we are not able to transform the value of %s to a string. Implements \\Stringable or add a 'choice_label' option to the filterFormBuilder", get_class($selected))); | ||||
|                         throw new \UnexpectedValueException(sprintf("we are not able to transform the value of %s to a string. Implements \\Stringable or add a 'choice_label' option to the filterFormBuilder", $selected::class)); | ||||
|                     } | ||||
|  | ||||
|                     $value = (string)$selected; | ||||
|   | ||||
| @@ -23,10 +23,6 @@ class FilterOrderHelperBuilder | ||||
|  | ||||
|     private array $dateRanges = []; | ||||
|  | ||||
|     private FormFactoryInterface $formFactory; | ||||
|  | ||||
|     private RequestStack $requestStack; | ||||
|  | ||||
|     private ?array $searchBoxFields = null; | ||||
|  | ||||
|     /** | ||||
| @@ -44,12 +40,8 @@ class FilterOrderHelperBuilder | ||||
|      */ | ||||
|     private array $userPickers = []; | ||||
|  | ||||
|     public function __construct( | ||||
|         FormFactoryInterface $formFactory, | ||||
|         RequestStack $requestStack, | ||||
|     ) { | ||||
|         $this->formFactory = $formFactory; | ||||
|         $this->requestStack = $requestStack; | ||||
|     public function __construct(private FormFactoryInterface $formFactory, private RequestStack $requestStack) | ||||
|     { | ||||
|     } | ||||
|  | ||||
|     public function addSingleCheckbox(string $name, string $label): self | ||||
|   | ||||
| @@ -18,16 +18,8 @@ use Symfony\Contracts\Translation\TranslatorInterface; | ||||
|  | ||||
| class FilterOrderHelperFactory implements FilterOrderHelperFactoryInterface | ||||
| { | ||||
|     private FormFactoryInterface $formFactory; | ||||
|  | ||||
|     private RequestStack $requestStack; | ||||
|  | ||||
|     public function __construct( | ||||
|         FormFactoryInterface $formFactory, | ||||
|         RequestStack $requestStack, | ||||
|     ) { | ||||
|         $this->formFactory = $formFactory; | ||||
|         $this->requestStack = $requestStack; | ||||
|     public function __construct(private FormFactoryInterface $formFactory, private RequestStack $requestStack) | ||||
|     { | ||||
|     } | ||||
|  | ||||
|     public function create(string $context, ?array $options = []): FilterOrderHelperBuilder | ||||
|   | ||||
| @@ -45,28 +45,13 @@ class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface | ||||
|         'compositionType', | ||||
|     ]; | ||||
|  | ||||
|     private ExportAddressHelper $addressHelper; | ||||
|  | ||||
|     private AggregateStringHelper $aggregateStringHelper; | ||||
|  | ||||
|     private EntityManagerInterface $entityManager; | ||||
|  | ||||
|     private RollingDateConverterInterface $rollingDateConverter; | ||||
|  | ||||
|     private TranslatableStringExportLabelHelper $translatableStringHelper; | ||||
|  | ||||
|     public function __construct( | ||||
|         ExportAddressHelper $addressHelper, | ||||
|         AggregateStringHelper $aggregateStringHelper, | ||||
|         EntityManagerInterface $entityManager, | ||||
|         RollingDateConverterInterface $rollingDateConverter, | ||||
|         TranslatableStringExportLabelHelper $translatableStringHelper | ||||
|         private ExportAddressHelper $addressHelper, | ||||
|         private AggregateStringHelper $aggregateStringHelper, | ||||
|         private EntityManagerInterface $entityManager, | ||||
|         private RollingDateConverterInterface $rollingDateConverter, | ||||
|         private TranslatableStringExportLabelHelper $translatableStringHelper | ||||
|     ) { | ||||
|         $this->addressHelper = $addressHelper; | ||||
|         $this->aggregateStringHelper = $aggregateStringHelper; | ||||
|         $this->entityManager = $entityManager; | ||||
|         $this->rollingDateConverter = $rollingDateConverter; | ||||
|         $this->translatableStringHelper = $translatableStringHelper; | ||||
|     } | ||||
|  | ||||
|     public function buildForm(FormBuilderInterface $builder) | ||||
| @@ -100,27 +85,21 @@ class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface | ||||
|  | ||||
|     public function getLabels($key, array $values, $data) | ||||
|     { | ||||
|         if (substr($key, 0, strlen('address_fields')) === 'address_fields') { | ||||
|         if (str_starts_with($key, 'address_fields')) { | ||||
|             return $this->addressHelper->getLabel($key, $values, $data, 'address_fields'); | ||||
|         } | ||||
|  | ||||
|         switch ($key) { | ||||
|             case 'membersId': | ||||
|             case 'membersName': | ||||
|                 return $this->aggregateStringHelper->getLabelMulti($key, $values, 'export.list.household.' . $key); | ||||
|         return match ($key) { | ||||
|             'membersId', 'membersName' => $this->aggregateStringHelper->getLabelMulti($key, $values, 'export.list.household.' . $key), | ||||
|             'compositionType' => $this->translatableStringHelper->getLabel($key, $values, 'export.list.household.' . $key), | ||||
|             default => static function ($value) use ($key) { | ||||
|                 if ('_header' === $value) { | ||||
|                     return 'export.list.household.' . $key; | ||||
|                 } | ||||
|  | ||||
|             case 'compositionType': | ||||
|                 return $this->translatableStringHelper->getLabel($key, $values, 'export.list.household.' . $key); | ||||
|  | ||||
|             default: | ||||
|                 return static function ($value) use ($key) { | ||||
|                     if ('_header' === $value) { | ||||
|                         return 'export.list.household.' . $key; | ||||
|                     } | ||||
|  | ||||
|                     return (string) $value; | ||||
|                 }; | ||||
|         } | ||||
|                 return (string) $value; | ||||
|             }, | ||||
|         }; | ||||
|     } | ||||
|  | ||||
|     public function getQueryKeys($data): array | ||||
|   | ||||
| @@ -39,16 +39,8 @@ class StepFilterBetweenDates implements FilterInterface | ||||
|         'course.inactive_long' => AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG, | ||||
|     ]; | ||||
|  | ||||
|     private RollingDateConverterInterface $rollingDateConverter; | ||||
|  | ||||
|     private TranslatorInterface $translator; | ||||
|  | ||||
|     public function __construct( | ||||
|         RollingDateConverterInterface $rollingDateConverter, | ||||
|         TranslatorInterface $translator | ||||
|     ) { | ||||
|         $this->rollingDateConverter = $rollingDateConverter; | ||||
|         $this->translator = $translator; | ||||
|     public function __construct(private RollingDateConverterInterface $rollingDateConverter, private TranslatorInterface $translator) | ||||
|     { | ||||
|     } | ||||
|  | ||||
|     public function addRole(): ?string | ||||
|   | ||||
| @@ -92,129 +92,104 @@ final readonly class ListAccompanyingPeriodHelper | ||||
|             return $this->addressHelper->getLabel($key, $values, $data, 'acp_address_fields'); | ||||
|         } | ||||
|  | ||||
|         switch ($key) { | ||||
|             case 'stepSince': | ||||
|             case 'openingDate': | ||||
|             case 'closingDate': | ||||
|             case 'referrerSince': | ||||
|             case 'acpCreatedAt': | ||||
|             case 'acpUpdatedAt': | ||||
|                 return $this->dateTimeHelper->getLabel('export.list.acp.' . $key); | ||||
|         return match ($key) { | ||||
|             'stepSince', 'openingDate', 'closingDate', 'referrerSince', 'acpCreatedAt', 'acpUpdatedAt' => $this->dateTimeHelper->getLabel('export.list.acp.' . $key), | ||||
|             'origin', 'closingMotive', 'job' => function ($value) use ($key) { | ||||
|                 if ('_header' === $value) { | ||||
|                     return 'export.list.acp.' . $key; | ||||
|                 } | ||||
|  | ||||
|             case 'origin': | ||||
|             case 'closingMotive': | ||||
|             case 'job': | ||||
|                 return function ($value) use ($key) { | ||||
|                     if ('_header' === $value) { | ||||
|                         return 'export.list.acp.' . $key; | ||||
|                     } | ||||
|                 if (null === $value) { | ||||
|                     return ''; | ||||
|                 } | ||||
|  | ||||
|                     if (null === $value) { | ||||
|                         return ''; | ||||
|                     } | ||||
|                 return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR)); | ||||
|             }, | ||||
|             'locationPersonName', 'requestorPerson' => function ($value) use ($key) { | ||||
|                 if ('_header' === $value) { | ||||
|                     return 'export.list.acp.' . $key; | ||||
|                 } | ||||
|  | ||||
|                     return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR)); | ||||
|                 }; | ||||
|                 if (null === $value || null === $person = $this->personRepository->find($value)) { | ||||
|                     return ''; | ||||
|                 } | ||||
|  | ||||
|             case 'locationPersonName': | ||||
|             case 'requestorPerson': | ||||
|                 return function ($value) use ($key) { | ||||
|                     if ('_header' === $value) { | ||||
|                         return 'export.list.acp.' . $key; | ||||
|                     } | ||||
|                 return $this->personRender->renderString($person, []); | ||||
|             }, | ||||
|             'requestorThirdParty' => function ($value) use ($key) { | ||||
|                 if ('_header' === $value) { | ||||
|                     return 'export.list.acp.' . $key; | ||||
|                 } | ||||
|  | ||||
|                     if (null === $value || null === $person = $this->personRepository->find($value)) { | ||||
|                         return ''; | ||||
|                     } | ||||
|                 if (null === $value || null === $thirdparty = $this->thirdPartyRepository->find($value)) { | ||||
|                     return ''; | ||||
|                 } | ||||
|  | ||||
|                     return $this->personRender->renderString($person, []); | ||||
|                 }; | ||||
|                 return $this->thirdPartyRender->renderString($thirdparty, []); | ||||
|             }, | ||||
|             'scopes' => function ($value) use ($key) { | ||||
|                 if ('_header' === $value) { | ||||
|                     return 'export.list.acp.' . $key; | ||||
|                 } | ||||
|  | ||||
|             case 'requestorThirdParty': | ||||
|                 return function ($value) use ($key) { | ||||
|                     if ('_header' === $value) { | ||||
|                         return 'export.list.acp.' . $key; | ||||
|                     } | ||||
|                 if (null === $value) { | ||||
|                     return ''; | ||||
|                 } | ||||
|  | ||||
|                     if (null === $value || null === $thirdparty = $this->thirdPartyRepository->find($value)) { | ||||
|                         return ''; | ||||
|                     } | ||||
|                 return implode( | ||||
|                     '|', | ||||
|                     array_map( | ||||
|                         fn ($s) => $this->translatableStringHelper->localize($s), | ||||
|                         json_decode($value, true, 512, JSON_THROW_ON_ERROR) | ||||
|                     ) | ||||
|                 ); | ||||
|             }, | ||||
|             'socialIssues' => function ($value) use ($key) { | ||||
|                 if ('_header' === $value) { | ||||
|                     return 'export.list.acp.' . $key; | ||||
|                 } | ||||
|  | ||||
|                     return $this->thirdPartyRender->renderString($thirdparty, []); | ||||
|                 }; | ||||
|                 if (null === $value) { | ||||
|                     return ''; | ||||
|                 } | ||||
|  | ||||
|             case 'scopes': | ||||
|                 return function ($value) use ($key) { | ||||
|                     if ('_header' === $value) { | ||||
|                         return 'export.list.acp.' . $key; | ||||
|                     } | ||||
|                 return implode( | ||||
|                     '|', | ||||
|                     array_map( | ||||
|                         fn ($s) => $this->socialIssueRender->renderString($this->socialIssueRepository->find($s), []), | ||||
|                         json_decode($value, true, 512, JSON_THROW_ON_ERROR) | ||||
|                     ) | ||||
|                 ); | ||||
|             }, | ||||
|             'step' => fn ($value) => match ($value) { | ||||
|                 '_header' => 'export.list.acp.step', | ||||
|                 null => '', | ||||
|                 AccompanyingPeriod::STEP_DRAFT => $this->translator->trans('course.draft'), | ||||
|                 AccompanyingPeriod::STEP_CONFIRMED => $this->translator->trans('course.confirmed'), | ||||
|                 AccompanyingPeriod::STEP_CLOSED => $this->translator->trans('course.closed'), | ||||
|                 AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT => $this->translator->trans('course.inactive_short'), | ||||
|                 AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG => $this->translator->trans('course.inactive_long'), | ||||
|                 default => $value, | ||||
|             }, | ||||
|             'intensity' => fn ($value) => match ($value) { | ||||
|                 '_header' => 'export.list.acp.intensity', | ||||
|                 null => '', | ||||
|                 AccompanyingPeriod::INTENSITY_OCCASIONAL => $this->translator->trans('occasional'), | ||||
|                 AccompanyingPeriod::INTENSITY_REGULAR => $this->translator->trans('regular'), | ||||
|                 default => $value, | ||||
|             }, | ||||
|             default => static function ($value) use ($key) { | ||||
|                 if ('_header' === $value) { | ||||
|                     return 'export.list.acp.' . $key; | ||||
|                 } | ||||
|  | ||||
|                     if (null === $value) { | ||||
|                         return ''; | ||||
|                     } | ||||
|                 if (null === $value) { | ||||
|                     return ''; | ||||
|                 } | ||||
|  | ||||
|                     return implode( | ||||
|                         '|', | ||||
|                         array_map( | ||||
|                             fn ($s) => $this->translatableStringHelper->localize($s), | ||||
|                             json_decode($value, true, 512, JSON_THROW_ON_ERROR) | ||||
|                         ) | ||||
|                     ); | ||||
|                 }; | ||||
|  | ||||
|             case 'socialIssues': | ||||
|                 return function ($value) use ($key) { | ||||
|                     if ('_header' === $value) { | ||||
|                         return 'export.list.acp.' . $key; | ||||
|                     } | ||||
|  | ||||
|                     if (null === $value) { | ||||
|                         return ''; | ||||
|                     } | ||||
|  | ||||
|                     return implode( | ||||
|                         '|', | ||||
|                         array_map( | ||||
|                             fn ($s) => $this->socialIssueRender->renderString($this->socialIssueRepository->find($s), []), | ||||
|                             json_decode($value, true, 512, JSON_THROW_ON_ERROR) | ||||
|                         ) | ||||
|                     ); | ||||
|                 }; | ||||
|  | ||||
|             case 'step': | ||||
|                 return fn ($value) => match ($value) { | ||||
|                     '_header' => 'export.list.acp.step', | ||||
|                     null => '', | ||||
|                     AccompanyingPeriod::STEP_DRAFT => $this->translator->trans('course.draft'), | ||||
|                     AccompanyingPeriod::STEP_CONFIRMED => $this->translator->trans('course.confirmed'), | ||||
|                     AccompanyingPeriod::STEP_CLOSED => $this->translator->trans('course.closed'), | ||||
|                     AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_SHORT => $this->translator->trans('course.inactive_short'), | ||||
|                     AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG => $this->translator->trans('course.inactive_long'), | ||||
|                     default => $value, | ||||
|                 }; | ||||
|  | ||||
|             case 'intensity': | ||||
|                 return fn ($value) => match ($value) { | ||||
|                     '_header' => 'export.list.acp.intensity', | ||||
|                     null => '', | ||||
|                     AccompanyingPeriod::INTENSITY_OCCASIONAL => $this->translator->trans('occasional'), | ||||
|                     AccompanyingPeriod::INTENSITY_REGULAR => $this->translator->trans('regular'), | ||||
|                     default => $value, | ||||
|                 }; | ||||
|  | ||||
|             default: | ||||
|                 return static function ($value) use ($key) { | ||||
|                     if ('_header' === $value) { | ||||
|                         return 'export.list.acp.' . $key; | ||||
|                     } | ||||
|  | ||||
|                     if (null === $value) { | ||||
|                         return ''; | ||||
|                     } | ||||
|  | ||||
|                     return $value; | ||||
|                 }; | ||||
|         } | ||||
|                 return $value; | ||||
|             }, | ||||
|         }; | ||||
|     } | ||||
|  | ||||
|     public function addSelectClauses(QueryBuilder $qb, \DateTimeImmutable $calcDate): void | ||||
|   | ||||
| @@ -24,12 +24,9 @@ class HouseholdMenuBuilder implements LocalMenuBuilderInterface | ||||
|      */ | ||||
|     protected $translator; | ||||
|  | ||||
|     private Security $security; | ||||
|  | ||||
|     public function __construct(TranslatorInterface $translator, Security $security) | ||||
|     public function __construct(TranslatorInterface $translator, private Security $security) | ||||
|     { | ||||
|         $this->translator = $translator; | ||||
|         $this->security = $security; | ||||
|     } | ||||
|  | ||||
|     public function buildMenu($menuId, MenuItem $menu, array $parameters): void | ||||
|   | ||||
| @@ -19,11 +19,8 @@ use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkEvalu | ||||
|  | ||||
| final class AccompanyingPeriodWorkEvaluationDocumentNotificationHandler implements NotificationHandlerInterface | ||||
| { | ||||
|     private AccompanyingPeriodWorkEvaluationDocumentRepository $accompanyingPeriodWorkEvaluationDocumentRepository; | ||||
|  | ||||
|     public function __construct(AccompanyingPeriodWorkEvaluationDocumentRepository $accompanyingPeriodWorkEvaluationDocumentRepository) | ||||
|     public function __construct(private AccompanyingPeriodWorkEvaluationDocumentRepository $accompanyingPeriodWorkEvaluationDocumentRepository) | ||||
|     { | ||||
|         $this->accompanyingPeriodWorkEvaluationDocumentRepository = $accompanyingPeriodWorkEvaluationDocumentRepository; | ||||
|     } | ||||
|  | ||||
|     public function getTemplate(Notification $notification, array $options = []): string | ||||
|   | ||||
| @@ -19,11 +19,8 @@ use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepos | ||||
|  | ||||
| final class AccompanyingPeriodWorkNotificationHandler implements NotificationHandlerInterface | ||||
| { | ||||
|     private AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository; | ||||
|  | ||||
|     public function __construct(AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository) | ||||
|     public function __construct(private AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository) | ||||
|     { | ||||
|         $this->accompanyingPeriodWorkRepository = $accompanyingPeriodWorkRepository; | ||||
|     } | ||||
|  | ||||
|     public function getTemplate(Notification $notification, array $options = []): string | ||||
|   | ||||
| @@ -37,24 +37,12 @@ use function count; | ||||
|  */ | ||||
| final readonly class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodACLAwareRepositoryInterface | ||||
| { | ||||
|     private AccompanyingPeriodRepository $accompanyingPeriodRepository; | ||||
|  | ||||
|     private AuthorizationHelperForCurrentUserInterface $authorizationHelper; | ||||
|  | ||||
|     private CenterResolverManagerInterface $centerResolver; | ||||
|  | ||||
|     private Security $security; | ||||
|  | ||||
|     public function __construct( | ||||
|         AccompanyingPeriodRepository $accompanyingPeriodRepository, | ||||
|         Security $security, | ||||
|         AuthorizationHelperForCurrentUserInterface $authorizationHelper, | ||||
|         CenterResolverManagerInterface $centerResolverDispatcher | ||||
|         private AccompanyingPeriodRepository $accompanyingPeriodRepository, | ||||
|         private Security $security, | ||||
|         private AuthorizationHelperForCurrentUserInterface $authorizationHelper, | ||||
|         private CenterResolverManagerInterface $centerResolver | ||||
|     ) { | ||||
|         $this->accompanyingPeriodRepository = $accompanyingPeriodRepository; | ||||
|         $this->security = $security; | ||||
|         $this->authorizationHelper = $authorizationHelper; | ||||
|         $this->centerResolver = $centerResolverDispatcher; | ||||
|     } | ||||
|  | ||||
|     public function buildQueryOpenedAccompanyingCourseByUserAndPostalCodes(?User $user, array $postalCodes = []): QueryBuilder | ||||
| @@ -178,7 +166,6 @@ final readonly class AccompanyingPeriodACLAwareRepository implements Accompanyin | ||||
|      * @param QueryBuilder $qb where the accompanying period have the `ap` alias | ||||
|      * @param array<Scope> $scopesCanSee | ||||
|      * @param array<Scope> $scopesCanSeeConfidential | ||||
|      * @return QueryBuilder | ||||
|      */ | ||||
|     public function addACLClauses(QueryBuilder $qb, array $scopesCanSee, array $scopesCanSeeConfidential): QueryBuilder | ||||
|     { | ||||
| @@ -272,10 +259,8 @@ final readonly class AccompanyingPeriodACLAwareRepository implements Accompanyin | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param QueryBuilder $qb | ||||
|      * @param list<array{center: Center, scopeOnRole: list<Scope>, scopeCanSeeConfidential: list<Scope>}> $centerScopes | ||||
|      * @param bool $allowNoCenter if true, will allow to see the periods linked to person which does not have any center. Very few edge case when some Person are not associated to a center. | ||||
|      * @return QueryBuilder | ||||
|      */ | ||||
|     public function addACLMultiCenterOnQuery(QueryBuilder $qb, array $centerScopes, bool $allowNoCenter = false): QueryBuilder | ||||
|     { | ||||
|   | ||||
| @@ -107,15 +107,12 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH | ||||
|      */ | ||||
|     public const SEE_CONFIDENTIAL_ALL = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE_CONFIDENTIAL'; | ||||
|  | ||||
|     private Security $security; | ||||
|  | ||||
|     private VoterHelperInterface $voterHelper; | ||||
|  | ||||
|     public function __construct( | ||||
|         Security $security, | ||||
|         private Security $security, | ||||
|         VoterHelperFactoryInterface $voterHelperFactory | ||||
|     ) { | ||||
|         $this->security = $security; | ||||
|         $this->voterHelper = $voterHelperFactory | ||||
|             ->generate(self::class) | ||||
|             ->addCheckFor(null, [self::CREATE, self::REASSIGN_BULK]) | ||||
|   | ||||
| @@ -51,48 +51,18 @@ class AccompanyingPeriodContext implements | ||||
|     DocGeneratorContextWithAdminFormInterface, | ||||
|     DocGeneratorContextWithPublicFormInterface | ||||
| { | ||||
|     private BaseContextData $baseContextData; | ||||
|  | ||||
|     private DocumentCategoryRepository $documentCategoryRepository; | ||||
|  | ||||
|     private EntityManagerInterface $em; | ||||
|  | ||||
|     private NormalizerInterface $normalizer; | ||||
|  | ||||
|     private PersonRenderInterface $personRender; | ||||
|  | ||||
|     private PersonRepository $personRepository; | ||||
|  | ||||
|     private TranslatableStringHelperInterface $translatableStringHelper; | ||||
|  | ||||
|     private TranslatorInterface $translator; | ||||
|  | ||||
|     private ThirdPartyRender $thirdPartyRender; | ||||
|  | ||||
|     private ThirdPartyRepository $thirdPartyRepository; | ||||
|  | ||||
|     public function __construct( | ||||
|         DocumentCategoryRepository $documentCategoryRepository, | ||||
|         NormalizerInterface $normalizer, | ||||
|         TranslatableStringHelperInterface $translatableStringHelper, | ||||
|         EntityManagerInterface $em, | ||||
|         PersonRenderInterface $personRender, | ||||
|         PersonRepository $personRepository, | ||||
|         TranslatorInterface $translator, | ||||
|         BaseContextData $baseContextData, | ||||
|         ThirdPartyRender $thirdPartyRender, | ||||
|         ThirdPartyRepository $thirdPartyRepository | ||||
|         private DocumentCategoryRepository $documentCategoryRepository, | ||||
|         private NormalizerInterface $normalizer, | ||||
|         private TranslatableStringHelperInterface $translatableStringHelper, | ||||
|         private EntityManagerInterface $em, | ||||
|         private PersonRenderInterface $personRender, | ||||
|         private PersonRepository $personRepository, | ||||
|         private TranslatorInterface $translator, | ||||
|         private BaseContextData $baseContextData, | ||||
|         private ThirdPartyRender $thirdPartyRender, | ||||
|         private ThirdPartyRepository $thirdPartyRepository | ||||
|     ) { | ||||
|         $this->documentCategoryRepository = $documentCategoryRepository; | ||||
|         $this->normalizer = $normalizer; | ||||
|         $this->translatableStringHelper = $translatableStringHelper; | ||||
|         $this->em = $em; | ||||
|         $this->personRender = $personRender; | ||||
|         $this->personRepository = $personRepository; | ||||
|         $this->translator = $translator; | ||||
|         $this->baseContextData = $baseContextData; | ||||
|         $this->thirdPartyRender = $thirdPartyRender; | ||||
|         $this->thirdPartyRepository = $thirdPartyRepository; | ||||
|     } | ||||
|  | ||||
|     public function adminFormReverseTransform(array $data): array | ||||
|   | ||||
| @@ -38,36 +38,8 @@ class AccompanyingPeriodWorkEvaluationContext implements | ||||
|     DocGeneratorContextWithAdminFormInterface, | ||||
|     DocGeneratorContextWithPublicFormInterface | ||||
| { | ||||
|     private AccompanyingPeriodWorkContext $accompanyingPeriodWorkContext; | ||||
|  | ||||
|     private EntityManagerInterface $em; | ||||
|  | ||||
|     private EvaluationRepository $evaluationRepository; | ||||
|  | ||||
|     private NormalizerInterface $normalizer; | ||||
|  | ||||
|     private TranslatableStringHelperInterface $translatableStringHelper; | ||||
|  | ||||
|     private ThirdPartyRender $thirdPartyRender; | ||||
|  | ||||
|     private TranslatorInterface $translator; | ||||
|  | ||||
|     public function __construct( | ||||
|         AccompanyingPeriodWorkContext $accompanyingPeriodWorkContext, | ||||
|         EntityManagerInterface $em, | ||||
|         EvaluationRepository $evaluationRepository, | ||||
|         NormalizerInterface $normalizer, | ||||
|         TranslatableStringHelperInterface $translatableStringHelper, | ||||
|         ThirdPartyRender $thirdPartyRender, | ||||
|         TranslatorInterface $translator | ||||
|     ) { | ||||
|         $this->accompanyingPeriodWorkContext = $accompanyingPeriodWorkContext; | ||||
|         $this->em = $em; | ||||
|         $this->evaluationRepository = $evaluationRepository; | ||||
|         $this->normalizer = $normalizer; | ||||
|         $this->translatableStringHelper = $translatableStringHelper; | ||||
|         $this->thirdPartyRender = $thirdPartyRender; | ||||
|         $this->translator = $translator; | ||||
|     public function __construct(private AccompanyingPeriodWorkContext $accompanyingPeriodWorkContext, private EntityManagerInterface $em, private EvaluationRepository $evaluationRepository, private NormalizerInterface $normalizer, private TranslatableStringHelperInterface $translatableStringHelper, private ThirdPartyRender $thirdPartyRender, private TranslatorInterface $translator) | ||||
|     { | ||||
|     } | ||||
|  | ||||
|     public function adminFormReverseTransform(array $data): array | ||||
|   | ||||
| @@ -56,64 +56,25 @@ use function count; | ||||
|  */ | ||||
| final class PersonContext implements PersonContextInterface | ||||
| { | ||||
|     private AuthorizationHelperInterface $authorizationHelper; | ||||
|  | ||||
|     private BaseContextData $baseContextData; | ||||
|  | ||||
|     private CenterResolverManagerInterface $centerResolverManager; | ||||
|  | ||||
|     private DocumentCategoryRepository $documentCategoryRepository; | ||||
|  | ||||
|     private EntityManagerInterface $em; | ||||
|  | ||||
|     private NormalizerInterface $normalizer; | ||||
|  | ||||
|     private ScopeRepositoryInterface $scopeRepository; | ||||
|  | ||||
|     private Security $security; | ||||
|  | ||||
|     private bool $showScopes; | ||||
|  | ||||
|     private TranslatableStringHelperInterface $translatableStringHelper; | ||||
|  | ||||
|     private TranslatorInterface $translator; | ||||
|  | ||||
|     private ThirdPartyRender $thirdPartyRender; | ||||
|  | ||||
|     private ThirdPartyRepository $thirdPartyRepository; | ||||
|  | ||||
|     private ResidentialAddressRepository $residentialAddressRepository; | ||||
|  | ||||
|     public function __construct( | ||||
|         AuthorizationHelperInterface $authorizationHelper, | ||||
|         BaseContextData $baseContextData, | ||||
|         CenterResolverManagerInterface $centerResolverManager, | ||||
|         DocumentCategoryRepository $documentCategoryRepository, | ||||
|         EntityManagerInterface $em, | ||||
|         NormalizerInterface $normalizer, | ||||
|         private AuthorizationHelperInterface $authorizationHelper, | ||||
|         private BaseContextData $baseContextData, | ||||
|         private CenterResolverManagerInterface $centerResolverManager, | ||||
|         private DocumentCategoryRepository $documentCategoryRepository, | ||||
|         private EntityManagerInterface $em, | ||||
|         private NormalizerInterface $normalizer, | ||||
|         ParameterBagInterface $parameterBag, | ||||
|         ScopeRepositoryInterface $scopeRepository, | ||||
|         Security $security, | ||||
|         TranslatorInterface $translator, | ||||
|         TranslatableStringHelperInterface $translatableStringHelper, | ||||
|         ThirdPartyRender $thirdPartyRender, | ||||
|         ThirdPartyRepository $thirdPartyRepository, | ||||
|         ResidentialAddressRepository $residentialAddressRepository | ||||
|         private ScopeRepositoryInterface $scopeRepository, | ||||
|         private Security $security, | ||||
|         private TranslatorInterface $translator, | ||||
|         private TranslatableStringHelperInterface $translatableStringHelper, | ||||
|         private ThirdPartyRender $thirdPartyRender, | ||||
|         private ThirdPartyRepository $thirdPartyRepository, | ||||
|         private ResidentialAddressRepository $residentialAddressRepository | ||||
|     ) { | ||||
|         $this->authorizationHelper = $authorizationHelper; | ||||
|         $this->centerResolverManager = $centerResolverManager; | ||||
|         $this->baseContextData = $baseContextData; | ||||
|         $this->documentCategoryRepository = $documentCategoryRepository; | ||||
|         $this->em = $em; | ||||
|         $this->normalizer = $normalizer; | ||||
|         $this->scopeRepository = $scopeRepository; | ||||
|         $this->security = $security; | ||||
|         $this->showScopes = $parameterBag->get('chill_main')['acl']['form_show_scopes']; | ||||
|         $this->translator = $translator; | ||||
|         $this->translatableStringHelper = $translatableStringHelper; | ||||
|         $this->thirdPartyRender = $thirdPartyRender; | ||||
|         $this->thirdPartyRepository = $thirdPartyRepository; | ||||
|         $this->residentialAddressRepository = $residentialAddressRepository; | ||||
|     } | ||||
|  | ||||
|     public function adminFormReverseTransform(array $data): array | ||||
|   | ||||
| @@ -488,9 +488,7 @@ class AccompanyingPeriodACLAwareRepositoryTest extends KernelTestCase | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param Person $person | ||||
|      * @param array<Scope> $scopes | ||||
|      * @return AccompanyingPeriod | ||||
|      */ | ||||
|     private function buildPeriod(Person $person, array $scopes, User|null $creator, bool $confirm): AccompanyingPeriod | ||||
|     { | ||||
|   | ||||
| @@ -44,11 +44,9 @@ class RelationshipNoDuplicateValidator extends ConstraintValidator | ||||
|  | ||||
|         foreach ($relationships as $r) { | ||||
|             if (spl_object_hash($r) !== spl_object_hash($value) | ||||
|                 and | ||||
|                 ( | ||||
|                 and ( | ||||
|                     ($r->getFromPerson() === $fromPerson and $r->getToPerson() === $toPerson) | ||||
|                     || | ||||
|                     ($r->getFromPerson() === $toPerson and $r->getToPerson() === $fromPerson) | ||||
|                     || ($r->getFromPerson() === $toPerson and $r->getToPerson() === $fromPerson) | ||||
|                 ) | ||||
|             ) { | ||||
|                 $this->context->buildViolation($constraint->message) | ||||
|   | ||||
| @@ -168,7 +168,7 @@ class LoadReports extends AbstractFixture implements ContainerAwareInterface, Or | ||||
|      * | ||||
|      * @return string|string[] | ||||
|      */ | ||||
|     private function getRandomChoice(CustomField $field) | ||||
|     private function getRandomChoice(CustomField $field): string|array | ||||
|     { | ||||
|         $choices = $field->getOptions()['choices']; | ||||
|         $multiple = $field->getOptions()['multiple']; | ||||
|   | ||||
| @@ -48,41 +48,17 @@ use function array_merge; | ||||
|  | ||||
| final class SingleTaskController extends AbstractController | ||||
| { | ||||
|     private CenterResolverDispatcherInterface $centerResolverDispatcher; | ||||
|  | ||||
|     private EventDispatcherInterface $eventDispatcher; | ||||
|  | ||||
|     private FilterOrderHelperFactoryInterface $filterOrderHelperFactory; | ||||
|  | ||||
|     private LoggerInterface $logger; | ||||
|  | ||||
|     private PaginatorFactory $paginatorFactory; | ||||
|  | ||||
|     private SingleTaskAclAwareRepositoryInterface $singleTaskAclAwareRepository; | ||||
|  | ||||
|     private TimelineBuilder $timelineBuilder; | ||||
|  | ||||
|     private TranslatorInterface $translator; | ||||
|  | ||||
|     public function __construct( | ||||
|         CenterResolverDispatcherInterface $centerResolverDispatcher, | ||||
|         PaginatorFactory $paginatorFactory, | ||||
|         SingleTaskAclAwareRepositoryInterface $singleTaskAclAwareRepository, | ||||
|         TranslatorInterface $translator, | ||||
|         EventDispatcherInterface $eventDispatcher, | ||||
|         TimelineBuilder $timelineBuilder, | ||||
|         LoggerInterface $logger, | ||||
|         FilterOrderHelperFactoryInterface $filterOrderHelperFactory, | ||||
|         private CenterResolverDispatcherInterface $centerResolverDispatcher, | ||||
|         private PaginatorFactory $paginatorFactory, | ||||
|         private SingleTaskAclAwareRepositoryInterface $singleTaskAclAwareRepository, | ||||
|         private TranslatorInterface $translator, | ||||
|         private EventDispatcherInterface $eventDispatcher, | ||||
|         private TimelineBuilder $timelineBuilder, | ||||
|         private LoggerInterface $logger, | ||||
|         private FilterOrderHelperFactoryInterface $filterOrderHelperFactory, | ||||
|         private SingleTaskStateRepository $singleTaskStateRepository | ||||
|     ) { | ||||
|         $this->eventDispatcher = $eventDispatcher; | ||||
|         $this->timelineBuilder = $timelineBuilder; | ||||
|         $this->logger = $logger; | ||||
|         $this->translator = $translator; | ||||
|         $this->centerResolverDispatcher = $centerResolverDispatcher; | ||||
|         $this->paginatorFactory = $paginatorFactory; | ||||
|         $this->singleTaskAclAwareRepository = $singleTaskAclAwareRepository; | ||||
|         $this->filterOrderHelperFactory = $filterOrderHelperFactory; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
| @@ -90,10 +66,8 @@ final class SingleTaskController extends AbstractController | ||||
|      *     "/{_locale}/task/single-task/{id}/delete", | ||||
|      *     name="chill_task_single_task_delete" | ||||
|      * ) | ||||
|      * | ||||
|      * @param mixed $id | ||||
|      */ | ||||
|     public function deleteAction(Request $request, $id) | ||||
|     public function deleteAction(Request $request, mixed $id) | ||||
|     { | ||||
|         $course = null; | ||||
|         $em = $this->getDoctrine()->getManager(); | ||||
| @@ -600,24 +574,19 @@ final class SingleTaskController extends AbstractController | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         switch ($entityType) { | ||||
|             case 'person': | ||||
|                 return $this->render('@ChillTask/SingleTask/Person/new.html.twig', [ | ||||
|                     'form' => $form->createView(), | ||||
|                     'task' => $task, | ||||
|                     'person' => $task->getPerson(), | ||||
|                 ]); | ||||
|  | ||||
|             case 'course': | ||||
|                 return $this->render('@ChillTask/SingleTask/AccompanyingCourse/new.html.twig', [ | ||||
|                     'form' => $form->createView(), | ||||
|                     'task' => $task, | ||||
|                     'accompanyingCourse' => $task->getCourse(), | ||||
|                 ]); | ||||
|  | ||||
|             default: | ||||
|                 throw new LogicException('entity context not supported'); | ||||
|         } | ||||
|         return match ($entityType) { | ||||
|             'person' => $this->render('@ChillTask/SingleTask/Person/new.html.twig', [ | ||||
|                 'form' => $form->createView(), | ||||
|                 'task' => $task, | ||||
|                 'person' => $task->getPerson(), | ||||
|             ]), | ||||
|             'course' => $this->render('@ChillTask/SingleTask/AccompanyingCourse/new.html.twig', [ | ||||
|                 'form' => $form->createView(), | ||||
|                 'task' => $task, | ||||
|                 'accompanyingCourse' => $task->getCourse(), | ||||
|             ]), | ||||
|             default => throw new LogicException('entity context not supported'), | ||||
|         }; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
| @@ -701,9 +670,8 @@ final class SingleTaskController extends AbstractController | ||||
|  | ||||
|     /** | ||||
|      * Creates a form to delete a Task entity by id. | ||||
|      * @param mixed $id | ||||
|      */ | ||||
|     private function createDeleteForm($id): FormInterface | ||||
|     private function createDeleteForm(mixed $id): FormInterface | ||||
|     { | ||||
|         return $this->createFormBuilder() | ||||
|             ->setAction($this->generateUrl( | ||||
|   | ||||
| @@ -186,6 +186,7 @@ class RecurringTask extends AbstractTask | ||||
|      * | ||||
|      * | ||||
|      * @return RecurringTask | ||||
|      * @param mixed $occurenceStartDate | ||||
|      */ | ||||
|     public function setOccurenceStartDate($occurenceStartDate) | ||||
|     { | ||||
| @@ -199,6 +200,7 @@ class RecurringTask extends AbstractTask | ||||
|      * | ||||
|      * | ||||
|      * @return RecurringTask | ||||
|      * @param mixed $occurenceWarningInterval | ||||
|      */ | ||||
|     public function setOccurenceWarningInterval($occurenceWarningInterval) | ||||
|     { | ||||
|   | ||||
| @@ -102,7 +102,7 @@ class ThirdPartyType extends AbstractType | ||||
|                     'label' => 'thirdparty.Contact data are confidential', | ||||
|                 ]); | ||||
|  | ||||
|             // Institutional ThirdParty (parent) | ||||
|         // Institutional ThirdParty (parent) | ||||
|         } else { | ||||
|             $builder | ||||
|                 ->add('nameCompany', TextType::class, [ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user