apply rules rector

This commit is contained in:
Julien Fastré 2023-07-19 22:48:26 +02:00
parent 6e6f19c499
commit 74ed34ba97
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
40 changed files with 250 additions and 697 deletions

View File

@ -77,10 +77,8 @@ final class ActivityController extends AbstractController
/** /**
* Deletes a Activity entity. * Deletes a Activity entity.
*
* @param mixed $id
*/ */
public function deleteAction(Request $request, $id) public function deleteAction(Request $request, mixed $id)
{ {
$view = null; $view = null;
@ -679,8 +677,8 @@ final class ActivityController extends AbstractController
throw $this->createNotFoundException('Accompanying Period not found'); throw $this->createNotFoundException('Accompanying Period not found');
} }
// TODO Add permission // TODO Add permission
// $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); // $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person);
} else { } else {
throw $this->createNotFoundException('Person or Accompanying Period not found'); throw $this->createNotFoundException('Person or Accompanying Period not found');
} }

View File

@ -94,17 +94,9 @@ class DateAggregator implements AggregatorInterface
return ''; return '';
} }
switch ($data['frequency']) { return match ($data['frequency']) {
case 'month': default => $value,
case 'week': };
//return $this->translator->trans('for week') .' '. $value ;
case 'year':
//return $this->translator->trans('in year') .' '. $value ;
default:
return $value;
}
}; };
} }

View File

@ -23,22 +23,8 @@ use Symfony\Contracts\Translation\TranslatorInterface;
*/ */
final class PersonMenuBuilder implements LocalMenuBuilderInterface final class PersonMenuBuilder implements LocalMenuBuilderInterface
{ {
/** public function __construct(private AuthorizationCheckerInterface $authorizationChecker, private TranslatorInterface $translator)
* @var AuthorizationCheckerInterface {
*/
private $authorizationChecker;
/**
* @var TranslatorInterface
*/
private $translator;
public function __construct(
AuthorizationCheckerInterface $authorizationChecker,
TranslatorInterface $translator
) {
$this->translator = $translator;
$this->authorizationChecker = $authorizationChecker;
} }
public function buildMenu($menuId, MenuItem $menu, array $parameters) public function buildMenu($menuId, MenuItem $menu, array $parameters)

View File

@ -42,48 +42,17 @@ class ActivityContext implements
DocGeneratorContextWithAdminFormInterface, DocGeneratorContextWithAdminFormInterface,
DocGeneratorContextWithPublicFormInterface 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( public function __construct(
DocumentCategoryRepository $documentCategoryRepository, private NormalizerInterface $normalizer,
NormalizerInterface $normalizer, private TranslatableStringHelperInterface $translatableStringHelper,
TranslatableStringHelperInterface $translatableStringHelper, private EntityManagerInterface $em,
EntityManagerInterface $em, private PersonRenderInterface $personRender,
PersonRenderInterface $personRender, private PersonRepository $personRepository,
PersonRepository $personRepository, private TranslatorInterface $translator,
TranslatorInterface $translator, private BaseContextData $baseContextData,
BaseContextData $baseContextData, private ThirdPartyRender $thirdPartyRender,
ThirdPartyRender $thirdPartyRender, private ThirdPartyRepository $thirdPartyRepository
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 public function adminFormReverseTransform(array $data): array

View File

@ -21,14 +21,8 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod;
final class AccompanyingPeriodActivityGenericDocRenderer implements GenericDocRendererInterface final class AccompanyingPeriodActivityGenericDocRenderer implements GenericDocRendererInterface
{ {
private StoredObjectRepository $objectRepository; public function __construct(private StoredObjectRepository $objectRepository, private ActivityRepository $activityRepository)
private ActivityRepository $activityRepository;
public function __construct(StoredObjectRepository $storedObjectRepository, ActivityRepository $activityRepository)
{ {
$this->objectRepository = $storedObjectRepository;
$this->activityRepository = $activityRepository;
} }
public function supports(GenericDocDTO $genericDocDTO, $options = []): bool public function supports(GenericDocDTO $genericDocDTO, $options = []): bool

View File

@ -19,11 +19,8 @@ use Chill\DocStoreBundle\GenericDoc\Twig\GenericDocRendererInterface;
final class AccompanyingPeriodCalendarGenericDocRenderer implements GenericDocRendererInterface final class AccompanyingPeriodCalendarGenericDocRenderer implements GenericDocRendererInterface
{ {
private CalendarDocRepository $repository; public function __construct(private CalendarDocRepository $repository)
public function __construct(CalendarDocRepository $calendarDocRepository)
{ {
$this->repository = $calendarDocRepository;
} }
public function supports(GenericDocDTO $genericDocDTO, $options = []): bool public function supports(GenericDocDTO $genericDocDTO, $options = []): bool

View File

@ -33,23 +33,14 @@ use Symfony\Contracts\Translation\TranslatorInterface;
*/ */
class DocumentAccompanyingCourseController extends AbstractController class DocumentAccompanyingCourseController extends AbstractController
{ {
protected AuthorizationHelper $authorizationHelper;
protected EventDispatcherInterface $eventDispatcher;
protected TranslatorInterface $translator;
/** /**
* DocumentAccompanyingCourseController constructor. * DocumentAccompanyingCourseController constructor.
*/ */
public function __construct( public function __construct(
TranslatorInterface $translator, protected TranslatorInterface $translator,
EventDispatcherInterface $eventDispatcher, protected EventDispatcherInterface $eventDispatcher,
AuthorizationHelper $authorizationHelper, protected AuthorizationHelper $authorizationHelper
) { ) {
$this->translator = $translator;
$this->eventDispatcher = $eventDispatcher;
$this->authorizationHelper = $authorizationHelper;
} }
/** /**

View File

@ -39,23 +39,14 @@ use Symfony\Contracts\Translation\TranslatorInterface;
*/ */
class DocumentPersonController extends AbstractController class DocumentPersonController extends AbstractController
{ {
protected AuthorizationHelper $authorizationHelper;
protected EventDispatcherInterface $eventDispatcher;
protected TranslatorInterface $translator;
/** /**
* DocumentPersonController constructor. * DocumentPersonController constructor.
*/ */
public function __construct( public function __construct(
TranslatorInterface $translator, protected TranslatorInterface $translator,
EventDispatcherInterface $eventDispatcher, protected EventDispatcherInterface $eventDispatcher,
AuthorizationHelper $authorizationHelper, protected AuthorizationHelper $authorizationHelper
) { ) {
$this->translator = $translator;
$this->eventDispatcher = $eventDispatcher;
$this->authorizationHelper = $authorizationHelper;
} }
/** /**

View File

@ -35,8 +35,6 @@ final readonly class GenericDocForAccompanyingPeriodController
} }
/** /**
* @param AccompanyingPeriod $accompanyingPeriod
* @return Response
* @throws \Doctrine\DBAL\Exception * @throws \Doctrine\DBAL\Exception
* *
* @Route("/{_locale}/doc-store/generic-doc/by-period/{id}/index", name="chill_docstore_generic-doc_by-period_index") * @Route("/{_locale}/doc-store/generic-doc/by-period/{id}/index", name="chill_docstore_generic-doc_by-period_index")

View File

@ -25,7 +25,6 @@ final readonly class FetchQueryToSqlBuilder
SQL; SQL;
/** /**
* @param FetchQueryInterface $query
* @return array{sql: string, params: list<mixed>, types: list<Types::*>} * @return array{sql: string, params: list<mixed>, types: list<Types::*>}
*/ */
public function toSql(FetchQueryInterface $query): array public function toSql(FetchQueryInterface $query): array

View File

@ -41,40 +41,13 @@ class EventSearch extends AbstractSearch
{ {
public const NAME = 'event_regular'; 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( public function __construct(
Security $security, private Security $security,
EventRepository $eventRepository, private EventRepository $er,
AuthorizationHelper $authorizationHelper, private AuthorizationHelper $authorizationHelper,
TemplatingEngine $templating, private TemplatingEngine $templating,
PaginatorFactory $paginatorFactory private PaginatorFactory $paginationFactory
) { ) {
$this->security = $security;
$this->er = $eventRepository;
$this->authorizationHelper = $authorizationHelper;
$this->templating = $templating;
$this->paginationFactory = $paginatorFactory;
} }
public function getOrder() public function getOrder()

View File

@ -52,57 +52,18 @@ use function unserialize;
*/ */
class ExportController extends AbstractController 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( public function __construct(
ChillRedis $chillRedis, private ChillRedis $redis,
ExportManager $exportManager, private ExportManager $exportManager,
FormFactoryInterface $formFactory, private FormFactoryInterface $formFactory,
LoggerInterface $logger, private LoggerInterface $logger,
SessionInterface $session, private SessionInterface $session,
TranslatorInterface $translator, private TranslatorInterface $translator,
EntityManagerInterface $entityManager, private EntityManagerInterface $entityManager,
private readonly ExportFormHelper $exportFormHelper, private readonly ExportFormHelper $exportFormHelper,
private readonly SavedExportRepositoryInterface $savedExportRepository, 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) public function downloadResultAction(Request $request, $alias)
@ -228,22 +189,13 @@ class ExportController extends AbstractController
$step = $request->query->getAlpha('step', 'centers'); $step = $request->query->getAlpha('step', 'centers');
switch ($step) { return match ($step) {
case 'centers': 'centers' => $this->selectCentersStep($request, $export, $alias, $savedExport),
return $this->selectCentersStep($request, $export, $alias, $savedExport); 'export' => $this->exportFormStep($request, $export, $alias, $savedExport),
'formatter' => $this->formatterFormStep($request, $export, $alias, $savedExport),
case 'export': 'generate' => $this->forwardToGenerate($request, $export, $alias, $savedExport),
return $this->exportFormStep($request, $export, $alias, $savedExport); default => throw $this->createNotFoundException("The given step '{$step}' is invalid"),
};
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");
}
} }
/** /**
@ -317,7 +269,7 @@ class ExportController extends AbstractController
{ {
/** @var \Chill\MainBundle\Export\ExportManager $exportManager */ /** @var \Chill\MainBundle\Export\ExportManager $exportManager */
$exportManager = $this->exportManager; $exportManager = $this->exportManager;
$isGenerate = strpos($step, 'generate_') === 0; $isGenerate = str_starts_with($step, 'generate_');
$options = match ($step) { $options = match ($step) {
'export', 'generate_export' => [ 'export', 'generate_export' => [
@ -493,7 +445,7 @@ class ExportController extends AbstractController
* *
* @return \Symfony\Component\HttpFoundation\RedirectResponse * @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); $dataCenters = $this->session->get('centers_step_raw', null);
$dataFormatter = $this->session->get('formatter_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 * @param string $alias
*
* @return Response * @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 */ /** @var \Chill\MainBundle\Export\ExportManager $exportManager */
$exportManager = $this->exportManager; $exportManager = $this->exportManager;
@ -647,7 +597,7 @@ class ExportController extends AbstractController
* *
* @return string the next/current step * @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) { switch ($step) {
case 'centers': case 'centers':

View File

@ -92,11 +92,9 @@ final readonly class UserExportController
} }
/** /**
* @return StreamedResponse
* @throws \League\Csv\CannotInsertRecord * @throws \League\Csv\CannotInsertRecord
* @throws \League\Csv\Exception * @throws \League\Csv\Exception
* @throws \League\Csv\UnavailableStream * @throws \League\Csv\UnavailableStream
*
* @Route("/{_locale}/admin/main/users/export/permissions.{_format}", requirements={"_format": "csv"}, name="chill_main_users_export_permissions") * @Route("/{_locale}/admin/main/users/export/permissions.{_format}", requirements={"_format": "csv"}, name="chill_main_users_export_permissions")
*/ */
public function userPermissionsList(string $_format = 'csv'): StreamedResponse public function userPermissionsList(string $_format = 'csv'): StreamedResponse

View File

@ -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), * 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. * and the last task execution is not recorded.
*/ */
class CronManager implements CronManagerInterface final readonly class CronManager implements CronManagerInterface
{ {
private const LOG_PREFIX = '[cron manager] '; 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 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 * @param CronJobInterface[] $jobs
*/ */
public function __construct( public function __construct(
CronJobExecutionRepositoryInterface $cronJobExecutionRepository, private CronJobExecutionRepositoryInterface $cronJobExecutionRepository,
EntityManagerInterface $entityManager, private EntityManagerInterface $entityManager,
iterable $jobs, private iterable $jobs,
LoggerInterface $logger private LoggerInterface $logger
) { ) {
$this->cronJobExecutionRepository = $cronJobExecutionRepository;
$this->entityManager = $entityManager;
$this->jobs = $jobs;
$this->logger = $logger;
} }
public function run(?string $forceJob = null): void 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()]); $this->logger->info(sprintf('%sSuccessfully run job', self::LOG_PREFIX), ['job' => $job->getKey()]);
return; return;
} catch (Exception $e) { } catch (Exception) {
$this->logger->error(sprintf('%sRunning job failed', self::LOG_PREFIX), ['job' => $job->getKey()]); $this->logger->error(sprintf('%sRunning job failed', self::LOG_PREFIX), ['job' => $job->getKey()]);
$this->entityManager $this->entityManager
->createQuery(self::UPDATE_AFTER_EXEC) ->createQuery(self::UPDATE_AFTER_EXEC)

View File

@ -24,12 +24,6 @@ class CronJobExecution
public const SUCCESS = 1; 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}) * @ORM\Column(type="datetime_immutable", nullable=true, options={"default": null})
*/ */
@ -50,9 +44,12 @@ class CronJobExecution
*/ */
private array $lastExecutionData = []; private array $lastExecutionData = [];
public function __construct(string $key) public function __construct(/**
{ * @ORM\Column(type="text", nullable=false)
$this->key = $key; * @ORM\Id
*/
private string $key
) {
$this->lastStart = new DateTimeImmutable('now'); $this->lastStart = new DateTimeImmutable('now');
} }

View File

@ -272,10 +272,7 @@ class User implements UserInterface, \Stringable
return ['ROLE_USER']; return ['ROLE_USER'];
} }
/** public function getSalt(): ?string
* @return string|null
*/
public function getSalt()
{ {
return $this->salt; return $this->salt;
} }

View File

@ -43,10 +43,6 @@ class ExportManager
*/ */
private array $aggregators = []; private array $aggregators = [];
private AuthorizationCheckerInterface $authorizationChecker;
private AuthorizationHelperInterface $authorizationHelper;
/** /**
* Collected Exports, injected by DI. * Collected Exports, injected by DI.
* *
@ -68,17 +64,15 @@ class ExportManager
*/ */
private array $formatters = []; private array $formatters = [];
private LoggerInterface $logger;
/** /**
* @var \Symfony\Component\Security\Core\User\UserInterface * @var \Symfony\Component\Security\Core\User\UserInterface
*/ */
private $user; private $user;
public function __construct( public function __construct(
LoggerInterface $logger, private LoggerInterface $logger,
AuthorizationCheckerInterface $authorizationChecker, private AuthorizationCheckerInterface $authorizationChecker,
AuthorizationHelperInterface $authorizationHelper, private AuthorizationHelperInterface $authorizationHelper,
TokenStorageInterface $tokenStorage, TokenStorageInterface $tokenStorage,
iterable $exports, iterable $exports,
iterable $aggregators, iterable $aggregators,
@ -86,9 +80,6 @@ class ExportManager
//iterable $formatters, //iterable $formatters,
//iterable $exportElementProvider //iterable $exportElementProvider
) { ) {
$this->logger = $logger;
$this->authorizationChecker = $authorizationChecker;
$this->authorizationHelper = $authorizationHelper;
$this->user = $tokenStorage->getToken()->getUser(); $this->user = $tokenStorage->getToken()->getUser();
$this->exports = iterator_to_array($exports); $this->exports = iterator_to_array($exports);
$this->aggregators = iterator_to_array($aggregators); $this->aggregators = iterator_to_array($aggregators);
@ -166,7 +157,7 @@ class ExportManager
} elseif ($element instanceof FormatterInterface) { } elseif ($element instanceof FormatterInterface) {
$this->addFormatter($element, $alias); $this->addFormatter($element, $alias);
} else { } else {
throw new LogicException('This element ' . get_class($element) . ' ' throw new LogicException('This element ' . $element::class . ' '
. 'is not an instance of export element'); . 'is not an instance of export element');
} }
} }
@ -285,7 +276,6 @@ class ExportManager
} }
/** /**
* @param array $aliases
* @return iterable<string, AggregatorInterface> * @return iterable<string, AggregatorInterface>
*/ */
public function getAggregators(array $aliases): iterable public function getAggregators(array $aliases): iterable
@ -352,7 +342,6 @@ class ExportManager
/** /**
* Get all exports grouped in an array. * 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 * @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 * @throws RuntimeException if the filter is not known
*/ */
public function getFilter(string $alias): FilterInterface 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 * 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. * 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) { if ($element instanceof ExportInterface || $element instanceof DirectExportInterface) {
$role = $element->requiredRole(); $role = $element->requiredRole();
@ -504,7 +489,7 @@ class ExportManager
//debugging //debugging
$this->logger->debug('user has no access to element', [ $this->logger->debug('user has no access to element', [
'method' => __METHOD__, 'method' => __METHOD__,
'type' => get_class($element), 'type' => $element::class,
'center' => $center->getName(), 'center' => $center->getName(),
'role' => $role, 'role' => $role,
]); ]);
@ -574,7 +559,7 @@ class ExportManager
private function handleFilters( private function handleFilters(
ExportInterface $export, ExportInterface $export,
QueryBuilder $qb, QueryBuilder $qb,
$data, mixed $data,
array $centers array $centers
) { ) {
$filters = $this->retrieveUsedFilters($data); $filters = $this->retrieveUsedFilters($data);
@ -595,11 +580,9 @@ class ExportManager
} }
/** /**
* @param mixed $data
*
* @return iterable<string, AggregatorInterface> * @return iterable<string, AggregatorInterface>
*/ */
private function retrieveUsedAggregators($data): iterable private function retrieveUsedAggregators(mixed $data): iterable
{ {
if (null === $data) { if (null === $data) {
return []; return [];
@ -613,11 +596,9 @@ class ExportManager
} }
/** /**
* @param mixed $data
*
* @return string[] * @return string[]
*/ */
private function retrieveUsedAggregatorsType($data) private function retrieveUsedAggregatorsType(mixed $data)
{ {
if (null === $data) { if (null === $data) {
return []; return [];
@ -657,7 +638,7 @@ class ExportManager
* *
* @return array an array with types * @return array an array with types
*/ */
private function retrieveUsedFiltersType($data) private function retrieveUsedFiltersType(mixed $data)
{ {
if (null === $data) { if (null === $data) {
return []; return [];
@ -681,11 +662,10 @@ class ExportManager
/** /**
* parse the data to retrieve the used filters and aggregators. * parse the data to retrieve the used filters and aggregators.
* *
* @param mixed $data
* *
* @return string[] * @return string[]
*/ */
private function retrieveUsedModifiers($data) private function retrieveUsedModifiers(mixed $data)
{ {
if (null === $data) { if (null === $data) {
return []; return [];

View File

@ -34,20 +34,11 @@ final class PickCenterType extends AbstractType
{ {
public const CENTERS_IDENTIFIERS = 'c'; public const CENTERS_IDENTIFIERS = 'c';
private AuthorizationHelperForCurrentUserInterface $authorizationHelper;
private ExportManager $exportManager;
private RegroupmentRepository $regroupmentRepository;
public function __construct( public function __construct(
ExportManager $exportManager, private ExportManager $exportManager,
RegroupmentRepository $regroupmentRepository, private RegroupmentRepository $regroupmentRepository,
AuthorizationHelperForCurrentUserInterface $authorizationHelper private AuthorizationHelperForCurrentUserInterface $authorizationHelper
) { ) {
$this->exportManager = $exportManager;
$this->authorizationHelper = $authorizationHelper;
$this->regroupmentRepository = $regroupmentRepository;
} }
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)

View File

@ -23,8 +23,6 @@ use Doctrine\Persistence\ObjectRepository;
final class NotificationRepository implements ObjectRepository final class NotificationRepository implements ObjectRepository
{ {
private EntityManagerInterface $em;
private ?Statement $notificationByRelatedEntityAndUserAssociatedStatement = null; private ?Statement $notificationByRelatedEntityAndUserAssociatedStatement = null;
private EntityRepository $repository; private EntityRepository $repository;
@ -38,10 +36,9 @@ final class NotificationRepository implements ObjectRepository
SQL; SQL;
public function __construct(EntityManagerInterface $entityManager) public function __construct(private EntityManagerInterface $em)
{ {
$this->em = $entityManager; $this->repository = $em->getRepository(Notification::class);
$this->repository = $entityManager->getRepository(Notification::class);
} }
public function countAllForAttendee(User $addressee): int public function countAllForAttendee(User $addressee): int

View File

@ -30,8 +30,7 @@ class PasswordRecoverEvent extends Event
private ?User $user = null, private ?User $user = null,
private $ip = null, private $ip = null,
private bool $safelyGenerated = false, private bool $safelyGenerated = false,
) ) {
{
} }
public function getIp() public function getIp()

View File

@ -28,7 +28,6 @@ final readonly class FilterOrderGetActiveFilterHelper
/** /**
* Return all the data required to display the active filters * Return all the data required to display the active filters
* *
* @param FilterOrderHelper $filterOrderHelper
* @return array<array{label: string, value: string, position: string, name: string}> * @return array<array{label: string, value: string, position: string, name: string}>
*/ */
public function getActiveFilters(FilterOrderHelper $filterOrderHelper): array public function getActiveFilters(FilterOrderHelper $filterOrderHelper): array
@ -65,7 +64,7 @@ final readonly class FilterOrderGetActiveFilterHelper
$value = $this->propertyAccessor->getValue($selected, $options['choice_label']); $value = $this->propertyAccessor->getValue($selected, $options['choice_label']);
} else { } else {
if (!$selected instanceof \Stringable) { 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; $value = (string)$selected;

View File

@ -23,10 +23,6 @@ class FilterOrderHelperBuilder
private array $dateRanges = []; private array $dateRanges = [];
private FormFactoryInterface $formFactory;
private RequestStack $requestStack;
private ?array $searchBoxFields = null; private ?array $searchBoxFields = null;
/** /**
@ -44,12 +40,8 @@ class FilterOrderHelperBuilder
*/ */
private array $userPickers = []; private array $userPickers = [];
public function __construct( public function __construct(private FormFactoryInterface $formFactory, private RequestStack $requestStack)
FormFactoryInterface $formFactory, {
RequestStack $requestStack,
) {
$this->formFactory = $formFactory;
$this->requestStack = $requestStack;
} }
public function addSingleCheckbox(string $name, string $label): self public function addSingleCheckbox(string $name, string $label): self

View File

@ -18,16 +18,8 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class FilterOrderHelperFactory implements FilterOrderHelperFactoryInterface class FilterOrderHelperFactory implements FilterOrderHelperFactoryInterface
{ {
private FormFactoryInterface $formFactory; public function __construct(private FormFactoryInterface $formFactory, private RequestStack $requestStack)
{
private RequestStack $requestStack;
public function __construct(
FormFactoryInterface $formFactory,
RequestStack $requestStack,
) {
$this->formFactory = $formFactory;
$this->requestStack = $requestStack;
} }
public function create(string $context, ?array $options = []): FilterOrderHelperBuilder public function create(string $context, ?array $options = []): FilterOrderHelperBuilder

View File

@ -45,28 +45,13 @@ class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface
'compositionType', 'compositionType',
]; ];
private ExportAddressHelper $addressHelper;
private AggregateStringHelper $aggregateStringHelper;
private EntityManagerInterface $entityManager;
private RollingDateConverterInterface $rollingDateConverter;
private TranslatableStringExportLabelHelper $translatableStringHelper;
public function __construct( public function __construct(
ExportAddressHelper $addressHelper, private ExportAddressHelper $addressHelper,
AggregateStringHelper $aggregateStringHelper, private AggregateStringHelper $aggregateStringHelper,
EntityManagerInterface $entityManager, private EntityManagerInterface $entityManager,
RollingDateConverterInterface $rollingDateConverter, private RollingDateConverterInterface $rollingDateConverter,
TranslatableStringExportLabelHelper $translatableStringHelper private TranslatableStringExportLabelHelper $translatableStringHelper
) { ) {
$this->addressHelper = $addressHelper;
$this->aggregateStringHelper = $aggregateStringHelper;
$this->entityManager = $entityManager;
$this->rollingDateConverter = $rollingDateConverter;
$this->translatableStringHelper = $translatableStringHelper;
} }
public function buildForm(FormBuilderInterface $builder) public function buildForm(FormBuilderInterface $builder)
@ -100,27 +85,21 @@ class ListHouseholdInPeriod implements ListInterface, GroupedExportInterface
public function getLabels($key, array $values, $data) 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'); return $this->addressHelper->getLabel($key, $values, $data, 'address_fields');
} }
switch ($key) { return match ($key) {
case 'membersId': 'membersId', 'membersName' => $this->aggregateStringHelper->getLabelMulti($key, $values, 'export.list.household.' . $key),
case 'membersName': 'compositionType' => $this->translatableStringHelper->getLabel($key, $values, 'export.list.household.' . $key),
return $this->aggregateStringHelper->getLabelMulti($key, $values, 'export.list.household.' . $key); default => static function ($value) use ($key) {
if ('_header' === $value) {
return 'export.list.household.' . $key;
}
case 'compositionType': return (string) $value;
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;
};
}
} }
public function getQueryKeys($data): array public function getQueryKeys($data): array

View File

@ -39,16 +39,8 @@ class StepFilterBetweenDates implements FilterInterface
'course.inactive_long' => AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG, 'course.inactive_long' => AccompanyingPeriod::STEP_CONFIRMED_INACTIVE_LONG,
]; ];
private RollingDateConverterInterface $rollingDateConverter; public function __construct(private RollingDateConverterInterface $rollingDateConverter, private TranslatorInterface $translator)
{
private TranslatorInterface $translator;
public function __construct(
RollingDateConverterInterface $rollingDateConverter,
TranslatorInterface $translator
) {
$this->rollingDateConverter = $rollingDateConverter;
$this->translator = $translator;
} }
public function addRole(): ?string public function addRole(): ?string

View File

@ -92,129 +92,104 @@ final readonly class ListAccompanyingPeriodHelper
return $this->addressHelper->getLabel($key, $values, $data, 'acp_address_fields'); return $this->addressHelper->getLabel($key, $values, $data, 'acp_address_fields');
} }
switch ($key) { return match ($key) {
case 'stepSince': 'stepSince', 'openingDate', 'closingDate', 'referrerSince', 'acpCreatedAt', 'acpUpdatedAt' => $this->dateTimeHelper->getLabel('export.list.acp.' . $key),
case 'openingDate': 'origin', 'closingMotive', 'job' => function ($value) use ($key) {
case 'closingDate': if ('_header' === $value) {
case 'referrerSince': return 'export.list.acp.' . $key;
case 'acpCreatedAt': }
case 'acpUpdatedAt':
return $this->dateTimeHelper->getLabel('export.list.acp.' . $key);
case 'origin': if (null === $value) {
case 'closingMotive': return '';
case 'job': }
return function ($value) use ($key) {
if ('_header' === $value) {
return 'export.list.acp.' . $key;
}
if (null === $value) { return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR));
return ''; },
} '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': return $this->personRender->renderString($person, []);
case 'requestorPerson': },
return function ($value) use ($key) { 'requestorThirdParty' => function ($value) use ($key) {
if ('_header' === $value) { if ('_header' === $value) {
return 'export.list.acp.' . $key; return 'export.list.acp.' . $key;
} }
if (null === $value || null === $person = $this->personRepository->find($value)) { if (null === $value || null === $thirdparty = $this->thirdPartyRepository->find($value)) {
return ''; 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': if (null === $value) {
return function ($value) use ($key) { return '';
if ('_header' === $value) { }
return 'export.list.acp.' . $key;
}
if (null === $value || null === $thirdparty = $this->thirdPartyRepository->find($value)) { return implode(
return ''; '|',
} 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 implode(
return function ($value) use ($key) { '|',
if ('_header' === $value) { array_map(
return 'export.list.acp.' . $key; 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) { if (null === $value) {
return ''; return '';
} }
return implode( return $value;
'|', },
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;
};
}
} }
public function addSelectClauses(QueryBuilder $qb, \DateTimeImmutable $calcDate): void public function addSelectClauses(QueryBuilder $qb, \DateTimeImmutable $calcDate): void

View File

@ -24,12 +24,9 @@ class HouseholdMenuBuilder implements LocalMenuBuilderInterface
*/ */
protected $translator; protected $translator;
private Security $security; public function __construct(TranslatorInterface $translator, private Security $security)
public function __construct(TranslatorInterface $translator, Security $security)
{ {
$this->translator = $translator; $this->translator = $translator;
$this->security = $security;
} }
public function buildMenu($menuId, MenuItem $menu, array $parameters): void public function buildMenu($menuId, MenuItem $menu, array $parameters): void

View File

@ -19,11 +19,8 @@ use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkEvalu
final class AccompanyingPeriodWorkEvaluationDocumentNotificationHandler implements NotificationHandlerInterface final class AccompanyingPeriodWorkEvaluationDocumentNotificationHandler implements NotificationHandlerInterface
{ {
private AccompanyingPeriodWorkEvaluationDocumentRepository $accompanyingPeriodWorkEvaluationDocumentRepository; public function __construct(private AccompanyingPeriodWorkEvaluationDocumentRepository $accompanyingPeriodWorkEvaluationDocumentRepository)
public function __construct(AccompanyingPeriodWorkEvaluationDocumentRepository $accompanyingPeriodWorkEvaluationDocumentRepository)
{ {
$this->accompanyingPeriodWorkEvaluationDocumentRepository = $accompanyingPeriodWorkEvaluationDocumentRepository;
} }
public function getTemplate(Notification $notification, array $options = []): string public function getTemplate(Notification $notification, array $options = []): string

View File

@ -19,11 +19,8 @@ use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepos
final class AccompanyingPeriodWorkNotificationHandler implements NotificationHandlerInterface final class AccompanyingPeriodWorkNotificationHandler implements NotificationHandlerInterface
{ {
private AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository; public function __construct(private AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository)
public function __construct(AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository)
{ {
$this->accompanyingPeriodWorkRepository = $accompanyingPeriodWorkRepository;
} }
public function getTemplate(Notification $notification, array $options = []): string public function getTemplate(Notification $notification, array $options = []): string

View File

@ -37,24 +37,12 @@ use function count;
*/ */
final readonly class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodACLAwareRepositoryInterface final readonly class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodACLAwareRepositoryInterface
{ {
private AccompanyingPeriodRepository $accompanyingPeriodRepository;
private AuthorizationHelperForCurrentUserInterface $authorizationHelper;
private CenterResolverManagerInterface $centerResolver;
private Security $security;
public function __construct( public function __construct(
AccompanyingPeriodRepository $accompanyingPeriodRepository, private AccompanyingPeriodRepository $accompanyingPeriodRepository,
Security $security, private Security $security,
AuthorizationHelperForCurrentUserInterface $authorizationHelper, private AuthorizationHelperForCurrentUserInterface $authorizationHelper,
CenterResolverManagerInterface $centerResolverDispatcher private CenterResolverManagerInterface $centerResolver
) { ) {
$this->accompanyingPeriodRepository = $accompanyingPeriodRepository;
$this->security = $security;
$this->authorizationHelper = $authorizationHelper;
$this->centerResolver = $centerResolverDispatcher;
} }
public function buildQueryOpenedAccompanyingCourseByUserAndPostalCodes(?User $user, array $postalCodes = []): QueryBuilder 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 QueryBuilder $qb where the accompanying period have the `ap` alias
* @param array<Scope> $scopesCanSee * @param array<Scope> $scopesCanSee
* @param array<Scope> $scopesCanSeeConfidential * @param array<Scope> $scopesCanSeeConfidential
* @return QueryBuilder
*/ */
public function addACLClauses(QueryBuilder $qb, array $scopesCanSee, array $scopesCanSeeConfidential): 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 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. * @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 public function addACLMultiCenterOnQuery(QueryBuilder $qb, array $centerScopes, bool $allowNoCenter = false): QueryBuilder
{ {

View File

@ -107,15 +107,12 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
*/ */
public const SEE_CONFIDENTIAL_ALL = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE_CONFIDENTIAL'; public const SEE_CONFIDENTIAL_ALL = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE_CONFIDENTIAL';
private Security $security;
private VoterHelperInterface $voterHelper; private VoterHelperInterface $voterHelper;
public function __construct( public function __construct(
Security $security, private Security $security,
VoterHelperFactoryInterface $voterHelperFactory VoterHelperFactoryInterface $voterHelperFactory
) { ) {
$this->security = $security;
$this->voterHelper = $voterHelperFactory $this->voterHelper = $voterHelperFactory
->generate(self::class) ->generate(self::class)
->addCheckFor(null, [self::CREATE, self::REASSIGN_BULK]) ->addCheckFor(null, [self::CREATE, self::REASSIGN_BULK])

View File

@ -51,48 +51,18 @@ class AccompanyingPeriodContext implements
DocGeneratorContextWithAdminFormInterface, DocGeneratorContextWithAdminFormInterface,
DocGeneratorContextWithPublicFormInterface 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( public function __construct(
DocumentCategoryRepository $documentCategoryRepository, private DocumentCategoryRepository $documentCategoryRepository,
NormalizerInterface $normalizer, private NormalizerInterface $normalizer,
TranslatableStringHelperInterface $translatableStringHelper, private TranslatableStringHelperInterface $translatableStringHelper,
EntityManagerInterface $em, private EntityManagerInterface $em,
PersonRenderInterface $personRender, private PersonRenderInterface $personRender,
PersonRepository $personRepository, private PersonRepository $personRepository,
TranslatorInterface $translator, private TranslatorInterface $translator,
BaseContextData $baseContextData, private BaseContextData $baseContextData,
ThirdPartyRender $thirdPartyRender, private ThirdPartyRender $thirdPartyRender,
ThirdPartyRepository $thirdPartyRepository 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 public function adminFormReverseTransform(array $data): array

View File

@ -38,36 +38,8 @@ class AccompanyingPeriodWorkEvaluationContext implements
DocGeneratorContextWithAdminFormInterface, DocGeneratorContextWithAdminFormInterface,
DocGeneratorContextWithPublicFormInterface DocGeneratorContextWithPublicFormInterface
{ {
private AccompanyingPeriodWorkContext $accompanyingPeriodWorkContext; public function __construct(private AccompanyingPeriodWorkContext $accompanyingPeriodWorkContext, private EntityManagerInterface $em, private EvaluationRepository $evaluationRepository, private NormalizerInterface $normalizer, private TranslatableStringHelperInterface $translatableStringHelper, private ThirdPartyRender $thirdPartyRender, private TranslatorInterface $translator)
{
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 adminFormReverseTransform(array $data): array public function adminFormReverseTransform(array $data): array

View File

@ -56,64 +56,25 @@ use function count;
*/ */
final class PersonContext implements PersonContextInterface 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 bool $showScopes;
private TranslatableStringHelperInterface $translatableStringHelper;
private TranslatorInterface $translator;
private ThirdPartyRender $thirdPartyRender;
private ThirdPartyRepository $thirdPartyRepository;
private ResidentialAddressRepository $residentialAddressRepository;
public function __construct( public function __construct(
AuthorizationHelperInterface $authorizationHelper, private AuthorizationHelperInterface $authorizationHelper,
BaseContextData $baseContextData, private BaseContextData $baseContextData,
CenterResolverManagerInterface $centerResolverManager, private CenterResolverManagerInterface $centerResolverManager,
DocumentCategoryRepository $documentCategoryRepository, private DocumentCategoryRepository $documentCategoryRepository,
EntityManagerInterface $em, private EntityManagerInterface $em,
NormalizerInterface $normalizer, private NormalizerInterface $normalizer,
ParameterBagInterface $parameterBag, ParameterBagInterface $parameterBag,
ScopeRepositoryInterface $scopeRepository, private ScopeRepositoryInterface $scopeRepository,
Security $security, private Security $security,
TranslatorInterface $translator, private TranslatorInterface $translator,
TranslatableStringHelperInterface $translatableStringHelper, private TranslatableStringHelperInterface $translatableStringHelper,
ThirdPartyRender $thirdPartyRender, private ThirdPartyRender $thirdPartyRender,
ThirdPartyRepository $thirdPartyRepository, private ThirdPartyRepository $thirdPartyRepository,
ResidentialAddressRepository $residentialAddressRepository 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->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 public function adminFormReverseTransform(array $data): array

View File

@ -488,9 +488,7 @@ class AccompanyingPeriodACLAwareRepositoryTest extends KernelTestCase
} }
/** /**
* @param Person $person
* @param array<Scope> $scopes * @param array<Scope> $scopes
* @return AccompanyingPeriod
*/ */
private function buildPeriod(Person $person, array $scopes, User|null $creator, bool $confirm): AccompanyingPeriod private function buildPeriod(Person $person, array $scopes, User|null $creator, bool $confirm): AccompanyingPeriod
{ {

View File

@ -44,11 +44,9 @@ class RelationshipNoDuplicateValidator extends ConstraintValidator
foreach ($relationships as $r) { foreach ($relationships as $r) {
if (spl_object_hash($r) !== spl_object_hash($value) if (spl_object_hash($r) !== spl_object_hash($value)
and and (
(
($r->getFromPerson() === $fromPerson and $r->getToPerson() === $toPerson) ($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) $this->context->buildViolation($constraint->message)

View File

@ -168,7 +168,7 @@ class LoadReports extends AbstractFixture implements ContainerAwareInterface, Or
* *
* @return string|string[] * @return string|string[]
*/ */
private function getRandomChoice(CustomField $field) private function getRandomChoice(CustomField $field): string|array
{ {
$choices = $field->getOptions()['choices']; $choices = $field->getOptions()['choices'];
$multiple = $field->getOptions()['multiple']; $multiple = $field->getOptions()['multiple'];

View File

@ -48,41 +48,17 @@ use function array_merge;
final class SingleTaskController extends AbstractController 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( public function __construct(
CenterResolverDispatcherInterface $centerResolverDispatcher, private CenterResolverDispatcherInterface $centerResolverDispatcher,
PaginatorFactory $paginatorFactory, private PaginatorFactory $paginatorFactory,
SingleTaskAclAwareRepositoryInterface $singleTaskAclAwareRepository, private SingleTaskAclAwareRepositoryInterface $singleTaskAclAwareRepository,
TranslatorInterface $translator, private TranslatorInterface $translator,
EventDispatcherInterface $eventDispatcher, private EventDispatcherInterface $eventDispatcher,
TimelineBuilder $timelineBuilder, private TimelineBuilder $timelineBuilder,
LoggerInterface $logger, private LoggerInterface $logger,
FilterOrderHelperFactoryInterface $filterOrderHelperFactory, private FilterOrderHelperFactoryInterface $filterOrderHelperFactory,
private SingleTaskStateRepository $singleTaskStateRepository 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", * "/{_locale}/task/single-task/{id}/delete",
* name="chill_task_single_task_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; $course = null;
$em = $this->getDoctrine()->getManager(); $em = $this->getDoctrine()->getManager();
@ -600,24 +574,19 @@ final class SingleTaskController extends AbstractController
} }
} }
switch ($entityType) { return match ($entityType) {
case 'person': 'person' => $this->render('@ChillTask/SingleTask/Person/new.html.twig', [
return $this->render('@ChillTask/SingleTask/Person/new.html.twig', [ 'form' => $form->createView(),
'form' => $form->createView(), 'task' => $task,
'task' => $task, 'person' => $task->getPerson(),
'person' => $task->getPerson(), ]),
]); 'course' => $this->render('@ChillTask/SingleTask/AccompanyingCourse/new.html.twig', [
'form' => $form->createView(),
case 'course': 'task' => $task,
return $this->render('@ChillTask/SingleTask/AccompanyingCourse/new.html.twig', [ 'accompanyingCourse' => $task->getCourse(),
'form' => $form->createView(), ]),
'task' => $task, default => throw new LogicException('entity context not supported'),
'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. * 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() return $this->createFormBuilder()
->setAction($this->generateUrl( ->setAction($this->generateUrl(

View File

@ -186,6 +186,7 @@ class RecurringTask extends AbstractTask
* *
* *
* @return RecurringTask * @return RecurringTask
* @param mixed $occurenceStartDate
*/ */
public function setOccurenceStartDate($occurenceStartDate) public function setOccurenceStartDate($occurenceStartDate)
{ {
@ -199,6 +200,7 @@ class RecurringTask extends AbstractTask
* *
* *
* @return RecurringTask * @return RecurringTask
* @param mixed $occurenceWarningInterval
*/ */
public function setOccurenceWarningInterval($occurenceWarningInterval) public function setOccurenceWarningInterval($occurenceWarningInterval)
{ {

View File

@ -102,7 +102,7 @@ class ThirdPartyType extends AbstractType
'label' => 'thirdparty.Contact data are confidential', 'label' => 'thirdparty.Contact data are confidential',
]); ]);
// Institutional ThirdParty (parent) // Institutional ThirdParty (parent)
} else { } else {
$builder $builder
->add('nameCompany', TextType::class, [ ->add('nameCompany', TextType::class, [