diff --git a/src/Bundle/ChillCalendarBundle/Repository/InviteRepository.php b/src/Bundle/ChillCalendarBundle/Repository/InviteRepository.php index 6ba967871..a1d56c792 100644 --- a/src/Bundle/ChillCalendarBundle/Repository/InviteRepository.php +++ b/src/Bundle/ChillCalendarBundle/Repository/InviteRepository.php @@ -86,15 +86,17 @@ class InviteRepository implements ObjectRepository $qb->expr()->eq('i.status', ':status') ) ) - ->setParameters([ - 'user' => $user, - 'status' => Invite::PENDING, - ]); + ->setParameters( + new \Doctrine\Common\Collections\ArrayCollection([ + new \Doctrine\ORM\Query\Parameter('user', $user), + new \Doctrine\ORM\Query\Parameter('status', Invite::PENDING), + ]) + ); return $qb->getQuery()->getSingleScalarResult(); } - public function buildAcceptedInviteByUserAndDateRangeQuery(User $user, \DateTimeImmutable $from, \DateTimeImmutable $to) + private function buildAcceptedInviteByUserAndDateRangeQuery(User $user, \DateTimeImmutable $from, \DateTimeImmutable $to): \Doctrine\ORM\QueryBuilder { $qb = $this->entityRepository->createQueryBuilder('i'); @@ -109,12 +111,16 @@ class InviteRepository implements ObjectRepository $qb->expr()->isNull('c.cancelReason') ) ) - ->setParameters([ - 'user' => $user, - 'status' => Invite::ACCEPTED, - 'startDate' => $from, - 'endDate' => $to, - ]); + ->setParameters( + new \Doctrine\Common\Collections\ArrayCollection( + [ + new \Doctrine\ORM\Query\Parameter('user', $user), + new \Doctrine\ORM\Query\Parameter('status', Invite::ACCEPTED), + new \Doctrine\ORM\Query\Parameter('startDate', $from), + new \Doctrine\ORM\Query\Parameter('endDate', $to), + ] + ) + ); } public function getClassName(): string diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php index 652cf3b20..e3d630c12 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php +++ b/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php @@ -189,10 +189,6 @@ class CRUDController extends AbstractController * build a default role name, using the crud resolver. * * This method should not be overriden. Override `getRoleFor` instead. - * - * @param string $action - * - * @return string */ protected function buildDefaultRole(string $action): string { diff --git a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadLocationType.php b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadLocationType.php index 985f5ba62..0d430e5f4 100644 --- a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadLocationType.php +++ b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadLocationType.php @@ -21,7 +21,6 @@ use Doctrine\Persistence\ObjectManager; */ class LoadLocationType extends Fixture implements OrderedFixtureInterface { - final public const LOCATION_TYPE = 'location_type'; public function getOrder(): int diff --git a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadUserJob.php b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadUserJob.php index d12648993..03952f786 100644 --- a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadUserJob.php +++ b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadUserJob.php @@ -19,6 +19,9 @@ use Doctrine\Persistence\ObjectManager; class LoadUserJob extends AbstractFixture implements OrderedFixtureInterface { final public const USER_JOB = 'user_job'; + /** + * @var array + */ private array $socialWorker = ['en' => 'social worker', 'fr' => 'travailleur social']; public function getOrder(): int diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/DateNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/DateNormalizer.php index 43617b794..c0f5d99ca 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/DateNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/DateNormalizer.php @@ -15,11 +15,10 @@ use DateTimeInterface; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\Serializer\Exception\UnexpectedValueException; -use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; -class DateNormalizer implements ContextAwareNormalizerInterface, NormalizerInterface, DenormalizerInterface +class DateNormalizer implements NormalizerInterface, DenormalizerInterface { public function __construct(private readonly RequestStack $requestStack, private readonly ParameterBagInterface $parameterBag) {} diff --git a/src/Bundle/ChillMainBundle/Tests/Notification/Email/DailyNotificationDigestCronJobTest.php b/src/Bundle/ChillMainBundle/Tests/Notification/Email/DailyNotificationDigestCronJobTest.php index 075929838..aa44a68f7 100644 --- a/src/Bundle/ChillMainBundle/Tests/Notification/Email/DailyNotificationDigestCronJobTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Notification/Email/DailyNotificationDigestCronJobTest.php @@ -120,7 +120,7 @@ class DailyNotificationDigestCronJobTest extends TestCase // Assert dispatch count and message contents self::assertCount(2, $dispatched); $expectedLast = $firstNow->sub(new \DateInterval('P1D')); - foreach ($dispatched as $i => $msg) { + foreach ($dispatched as $msg) { self::assertInstanceOf(ScheduleDailyNotificationDigestMessage::class, $msg); self::assertTrue(in_array($msg->getUserId(), [10, 42], true)); self::assertEquals($firstNow, $msg->getCurrentDateTime(), 'compare the current date'); diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonIdentifierListApiController.php b/src/Bundle/ChillPersonBundle/Controller/PersonIdentifierListApiController.php index 2f0b3af28..26bfc7db1 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonIdentifierListApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonIdentifierListApiController.php @@ -14,11 +14,11 @@ namespace Chill\PersonBundle\Controller; use Chill\MainBundle\Pagination\PaginatorFactoryInterface; use Chill\MainBundle\Serializer\Model\Collection; use Chill\PersonBundle\PersonIdentifier\PersonIdentifierManagerInterface; +use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\Routing\Annotation\Route; -use Symfony\Component\Security\Core\Security; use Symfony\Component\Serializer\SerializerInterface; final readonly class PersonIdentifierListApiController diff --git a/src/Bundle/ChillPersonBundle/Form/PersonIdentifiersType.php b/src/Bundle/ChillPersonBundle/Form/PersonIdentifiersType.php index 199b89bc8..4f7dc961c 100644 --- a/src/Bundle/ChillPersonBundle/Form/PersonIdentifiersType.php +++ b/src/Bundle/ChillPersonBundle/Form/PersonIdentifiersType.php @@ -29,7 +29,7 @@ final class PersonIdentifiersType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options): void { - foreach ($this->identifierManager->getWorkers() as $k => $worker) { + foreach ($this->identifierManager->getWorkers() as $worker) { if (!$worker->getDefinition()->isEditableByUsers()) { continue; } diff --git a/src/Bundle/ChillPersonBundle/PersonIdentifier/Normalizer/PersonIdentifierWorkerNormalizer.php b/src/Bundle/ChillPersonBundle/PersonIdentifier/Normalizer/PersonIdentifierWorkerNormalizer.php index 432dea50c..5991f653c 100644 --- a/src/Bundle/ChillPersonBundle/PersonIdentifier/Normalizer/PersonIdentifierWorkerNormalizer.php +++ b/src/Bundle/ChillPersonBundle/PersonIdentifier/Normalizer/PersonIdentifierWorkerNormalizer.php @@ -32,8 +32,13 @@ final readonly class PersonIdentifierWorkerNormalizer implements NormalizerInter ]; } - public function supportsNormalization($data, ?string $format = null): bool + public function supportsNormalization($data, ?string $format = null, array $context = []): bool { return $data instanceof PersonIdentifierWorker; } + + public function getSupportedTypes(?string $format): array + { + return 'json' === $format ? [PersonIdentifierWorker::class => true] : []; + } } diff --git a/src/Bundle/ChillPersonBundle/Repository/Identifier/PersonIdentifierRepository.php b/src/Bundle/ChillPersonBundle/Repository/Identifier/PersonIdentifierRepository.php index e3af66e31..a81d99922 100644 --- a/src/Bundle/ChillPersonBundle/Repository/Identifier/PersonIdentifierRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/Identifier/PersonIdentifierRepository.php @@ -17,6 +17,9 @@ use Chill\PersonBundle\PersonIdentifier\PersonIdentifierManagerInterface; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; +/** + * @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\PersonBundle\Entity\Identifier\PersonIdentifier> + */ class PersonIdentifierRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry, private readonly PersonIdentifierManagerInterface $personIdentifierManager) diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php index b8bda032b..ab6b55ac8 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonDocGenNormalizer.php @@ -42,10 +42,10 @@ class PersonDocGenNormalizer implements public function __construct(private readonly PersonRenderInterface $personRender, private readonly RelationshipRepository $relationshipRepository, private readonly TranslatableStringHelper $translatableStringHelper, private readonly SummaryBudgetInterface $summaryBudget) {} - public function normalize($person, $format = null, array $context = []): string|int|float|bool|\ArrayObject|array|null + public function normalize($data, $format = null, array $context = []): string|int|float|bool|\ArrayObject|array|null { try { - $context = $this->addCircularToContext($person, $context); + $context = $this->addCircularToContext($data, $context); } catch (CircularReferenceException) { return [ 'isNull' => true, @@ -54,7 +54,7 @@ class PersonDocGenNormalizer implements ]; } - /** @var Person $person */ + /** @var Person $data */ $dateContext = $context; $dateContext['docgen:expects'] = \DateTimeInterface::class; $addressContext = array_merge($context, ['docgen:expects' => Address::class]); @@ -69,53 +69,53 @@ class PersonDocGenNormalizer implements ]); $genderContext = array_merge($context, ['docgen:expects' => Gender::class]); - if (null === $person) { + if (null === $data) { return $this->normalizeNullValue($format, $context); } - if (!$person instanceof Person) { + if (!$data instanceof Person) { throw new UnexpectedValueException(); } $data = [ 'type' => 'person', - 'id' => $person->getId(), + 'id' => $data->getId(), 'isNull' => false, - 'civility' => $this->normalizer->normalize($person->getCivility(), $format, array_merge($context, ['docgen:expects' => Civility::class])), - 'firstName' => $person->getFirstName(), - 'lastName' => $person->getLastName(), + 'civility' => $this->normalizer->normalize($data->getCivility(), $format, array_merge($context, ['docgen:expects' => Civility::class])), + 'firstName' => $data->getFirstName(), + 'lastName' => $data->getLastName(), 'altNames' => \implode( ', ', \array_map( static fn (PersonAltName $altName) => $altName->getLabel(), - $person->getAltNames()->toArray() + $data->getAltNames()->toArray() ) ), - 'text' => $this->personRender->renderString($person, []), - 'age' => (int) $person->getAge(), - 'birthdate' => $this->normalizer->normalize($person->getBirthdate(), $format, $dateContext), - 'deathdate' => $this->normalizer->normalize($person->getDeathdate(), $format, $dateContext), - 'gender' => null !== ($g = $person->getGender()) ? $this->translatableStringHelper->localize($g->getLabel()) : '', - 'genderEntity' => $this->normalizer->normalize($person->getGender(), $format, $genderContext), - 'maritalStatus' => null !== ($ms = $person->getMaritalStatus()) ? $this->translatableStringHelper->localize($ms->getName()) : '', - 'maritalStatusDate' => $this->normalizer->normalize($person->getMaritalStatusDate(), $format, $dateContext), - 'maritalStatusComment' => $this->normalizer->normalize($person->getMaritalStatusComment(), $format, $dateContext), - 'email' => $person->getEmail(), - 'firstPhoneNumber' => $this->normalizer->normalize($person->getPhonenumber() ?? $person->getMobilenumber(), $format, $phonenumberContext), - 'fixPhoneNumber' => $this->normalizer->normalize($person->getPhonenumber(), $format, $phonenumberContext), - 'mobilePhoneNumber' => $this->normalizer->normalize($person->getMobilenumber(), $format, $phonenumberContext), - 'nationality' => null !== ($c = $person->getNationality()) ? $this->translatableStringHelper->localize($c->getName()) : '', - 'placeOfBirth' => $person->getPlaceOfBirth(), - 'memo' => $person->getMemo(), - 'numberOfChildren' => (string) $person->getNumberOfChildren(), - 'address' => $this->normalizer->normalize($person->getCurrentPersonAddress(), $format, $addressContext), - 'resources' => $this->normalizer->normalize($person->getResources(), $format, $personResourceContext), - 'center' => $this->normalizer->normalize($person->getCenter(), $format, $centerContext), + 'text' => $this->personRender->renderString($data, []), + 'age' => (int) $data->getAge(), + 'birthdate' => $this->normalizer->normalize($data->getBirthdate(), $format, $dateContext), + 'deathdate' => $this->normalizer->normalize($data->getDeathdate(), $format, $dateContext), + 'gender' => null !== ($g = $data->getGender()) ? $this->translatableStringHelper->localize($g->getLabel()) : '', + 'genderEntity' => $this->normalizer->normalize($data->getGender(), $format, $genderContext), + 'maritalStatus' => null !== ($ms = $data->getMaritalStatus()) ? $this->translatableStringHelper->localize($ms->getName()) : '', + 'maritalStatusDate' => $this->normalizer->normalize($data->getMaritalStatusDate(), $format, $dateContext), + 'maritalStatusComment' => $this->normalizer->normalize($data->getMaritalStatusComment(), $format, $dateContext), + 'email' => $data->getEmail(), + 'firstPhoneNumber' => $this->normalizer->normalize($data->getPhonenumber() ?? $data->getMobilenumber(), $format, $phonenumberContext), + 'fixPhoneNumber' => $this->normalizer->normalize($data->getPhonenumber(), $format, $phonenumberContext), + 'mobilePhoneNumber' => $this->normalizer->normalize($data->getMobilenumber(), $format, $phonenumberContext), + 'nationality' => null !== ($c = $data->getNationality()) ? $this->translatableStringHelper->localize($c->getName()) : '', + 'placeOfBirth' => $data->getPlaceOfBirth(), + 'memo' => $data->getMemo(), + 'numberOfChildren' => (string) $data->getNumberOfChildren(), + 'address' => $this->normalizer->normalize($data->getCurrentPersonAddress(), $format, $addressContext), + 'resources' => $this->normalizer->normalize($data->getResources(), $format, $personResourceContext), + 'center' => $this->normalizer->normalize($data->getCenter(), $format, $centerContext), ]; if ($context['docgen:person:with-household'] ?? false) { $data['household'] = $this->normalizer->normalize( - $person->getCurrentHousehold(), + $data->getCurrentHousehold(), $format, array_merge($context, [ 'docgen:expects' => Household::class, @@ -128,22 +128,22 @@ class PersonDocGenNormalizer implements if ($context['docgen:person:with-relations'] ?? false) { $data['relations'] = $this->normalizer->normalize( - new ArrayCollection($this->relationshipRepository->findByPerson($person)), + new ArrayCollection($this->relationshipRepository->findByPerson($data)), $format, array_merge($context, [ 'docgen:person:with-household' => false, 'docgen:person:with-relation' => false, - 'docgen:relationship:counterpart' => $person, + 'docgen:relationship:counterpart' => $data, 'docgen:person:with-budget' => false, ]) ); } if ($context['docgen:person:with-budget'] ?? false) { - $data['budget']['person'] = $this->summaryBudget->getSummaryForPerson($person); + $data['budget']['person'] = $this->summaryBudget->getSummaryForPerson($data); if ($context['docgen:person:with-household'] ?? false) { - $data['budget']['household'] = $this->summaryBudget->getSummaryForHousehold($person->getCurrentHousehold()); + $data['budget']['household'] = $this->summaryBudget->getSummaryForHousehold($data->getCurrentHousehold()); } } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonDenormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonDenormalizer.php index 9f0464a71..2bfbc07f2 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonDenormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonDenormalizer.php @@ -148,8 +148,17 @@ final class PersonJsonDenormalizer implements DenormalizerInterface, Denormalize return $person; } - public function supportsDenormalization($data, $type, $format = null): bool + public function supportsDenormalization($data, $type, $format = null, array $context = []): bool { return Person::class === $type && 'person' === ($data['type'] ?? null) && !isset($data['id']); } + + public function getSupportedTypes(?string $format): array + { + if ('json' === $format) { + return [Person::class => false]; + } + + return []; + } } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php index 8467c1d56..dcbd8e474 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonNormalizer.php @@ -18,6 +18,7 @@ use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\PersonAltName; use Chill\PersonBundle\Repository\ResidentialAddressRepository; use Doctrine\Common\Collections\Collection; +use Symfony\Component\Serializer\Exception\UnexpectedValueException; use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait; @@ -38,50 +39,54 @@ class PersonJsonNormalizer implements NormalizerAwareInterface, NormalizerInterf private readonly \Chill\PersonBundle\PersonIdentifier\Rendering\PersonIdRenderingInterface $personIdRendering, ) {} - /** - * @param Person $person - * @param string|null $format - */ - public function normalize($person, $format = null, array $context = []) + public function normalize($data, $format = null, array $context = []): array { + if (!$data instanceof Person) { + throw new UnexpectedValueException(sprintf('Expected %s, got %s', Person::class, is_object($data) ? get_class($data) : gettype($data))); + } + $groups = $context[AbstractNormalizer::GROUPS] ?? []; if (\is_string($groups)) { $groups = [$groups]; } - $household = $person->getCurrentHousehold(); - $currentResidentialAddresses = $this->residentialAddressRepository->findCurrentResidentialAddressByPerson($person); + $household = $data->getCurrentHousehold(); + $currentResidentialAddresses = $this->residentialAddressRepository->findCurrentResidentialAddressByPerson($data); - $data = [ + $normalizedData = [ 'type' => 'person', - 'id' => $person->getId(), - 'text' => $this->render->renderString($person, ['addAge' => false]), - 'textAge' => $this->render->renderString($person, ['addAge' => true]), - 'firstName' => $person->getFirstName(), - 'lastName' => $person->getLastName(), - 'current_household_address' => $this->normalizer->normalize($person->getCurrentHouseholdAddress(), $format, $context), - 'birthdate' => $this->normalizer->normalize($person->getBirthdate(), $format, $context), - 'deathdate' => $this->normalizer->normalize($person->getDeathdate(), $format, $context), - 'age' => $this->normalizer->normalize($person->getAge(), $format, $context), - 'phonenumber' => $this->normalizer->normalize($person->getPhonenumber(), $format, $context), - 'mobilenumber' => $this->normalizer->normalize($person->getMobilenumber(), $format, $context), - 'email' => $person->getEmail(), - 'gender' => $this->normalizer->normalize($person->getGender(), $format, $context), - 'civility' => $this->normalizer->normalize($person->getCivility(), $format, $context), - 'personId' => $this->personIdRendering->renderPersonId($person), - 'identifiers' => $this->normalizer->normalize($person->getIdentifiers(), $format, $context), + 'id' => $data->getId(), + 'text' => $this->render->renderString($data, ['addAge' => false]), + 'textAge' => $this->render->renderString($data, ['addAge' => true]), + 'firstName' => $data->getFirstName(), + 'lastName' => $data->getLastName(), + 'current_household_address' => $this->normalizer->normalize($data->getCurrentHouseholdAddress(), $format, $context), + 'birthdate' => $this->normalizer->normalize($data->getBirthdate(), $format, $context), + 'deathdate' => $this->normalizer->normalize($data->getDeathdate(), $format, $context), + 'age' => $this->normalizer->normalize($data->getAge(), $format, $context), + 'phonenumber' => $this->normalizer->normalize($data->getPhonenumber(), $format, $context), + 'mobilenumber' => $this->normalizer->normalize($data->getMobilenumber(), $format, $context), + 'email' => $data->getEmail(), + 'gender' => $this->normalizer->normalize($data->getGender(), $format, $context), + 'civility' => $this->normalizer->normalize($data->getCivility(), $format, $context), + 'personId' => $this->personIdRendering->renderPersonId($data), + 'identifiers' => $this->normalizer->normalize($data->getIdentifiers(), $format, $context), ]; if (\in_array('minimal', $groups, true) && 1 === \count($groups)) { - return $data; + return $normalizedData; } - return [...$data, 'centers' => $this->normalizer->normalize($this->centerResolverManager->resolveCenters($person), $format, $context), 'altNames' => $this->normalizeAltNames($person->getAltNames()), 'current_household_id' => $household ? $this->normalizer->normalize($household->getId(), $format, $context) : null, 'current_residential_addresses' => $currentResidentialAddresses ? - $this->normalizer->normalize($currentResidentialAddresses, $format, $context) : - null]; + return [ + ...$normalizedData, + 'centers' => $this->normalizer->normalize($this->centerResolverManager->resolveCenters($data), $format, $context), + 'altNames' => $this->normalizeAltNames($data->getAltNames()), + 'current_household_id' => $household ? $this->normalizer->normalize($household->getId(), $format, $context) : null, + 'current_residential_addresses' => $currentResidentialAddresses ? $this->normalizer->normalize($currentResidentialAddresses, $format, $context) : null, + ]; } - public function supportsNormalization($data, $format = null): bool + public function supportsNormalization($data, $format = null, array $context = []): bool { return $data instanceof Person && 'json' === $format; } @@ -91,7 +96,7 @@ class PersonJsonNormalizer implements NormalizerAwareInterface, NormalizerInterf * * @return array> */ - protected function normalizeAltNames(Collection $altNames): array + private function normalizeAltNames(Collection $altNames): array { return $altNames ->map( @@ -105,6 +110,6 @@ class PersonJsonNormalizer implements NormalizerAwareInterface, NormalizerInterf public function getSupportedTypes(?string $format): array { - return 'json' === $format ? [Person::class => true] : []; + return 'json' === $format ? [Person::class => false] : []; } } diff --git a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonReadDenormalizer.php b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonReadDenormalizer.php index ce8e5ce48..f93f2dff9 100644 --- a/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonReadDenormalizer.php +++ b/src/Bundle/ChillPersonBundle/Serializer/Normalizer/PersonJsonReadDenormalizer.php @@ -44,8 +44,13 @@ readonly class PersonJsonReadDenormalizer implements DenormalizerInterface throw new LogicException(); } - public function supportsDenormalization($data, string $type, ?string $format = null) + public function supportsDenormalization($data, string $type, ?string $format = null, array $context = []): bool { return is_array($data) && Person::class === $type && 'person' === ($data['type'] ?? null) && isset($data['id']); } + + public function getSupportedTypes(?string $format): array + { + return 'json' === $format ? [Person::class => true] : []; + } } diff --git a/src/Bundle/ChillTicketBundle/src/Action/Ticket/Handler/SetAddresseesCommandHandler.php b/src/Bundle/ChillTicketBundle/src/Action/Ticket/Handler/SetAddresseesCommandHandler.php index b2805ed2f..2b2c7f7be 100644 --- a/src/Bundle/ChillTicketBundle/src/Action/Ticket/Handler/SetAddresseesCommandHandler.php +++ b/src/Bundle/ChillTicketBundle/src/Action/Ticket/Handler/SetAddresseesCommandHandler.php @@ -16,8 +16,8 @@ use Chill\TicketBundle\Action\Ticket\SetAddresseesCommand; use Chill\TicketBundle\Entity\AddresseeHistory; use Chill\TicketBundle\Entity\Ticket; use Doctrine\ORM\EntityManagerInterface; +use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\Clock\ClockInterface; -use Symfony\Component\Security\Core\Security; final readonly class SetAddresseesCommandHandler { diff --git a/src/Bundle/ChillTicketBundle/src/Action/Ticket/Handler/SetPersonsCommandHandler.php b/src/Bundle/ChillTicketBundle/src/Action/Ticket/Handler/SetPersonsCommandHandler.php index cab723e7f..d8fed09cc 100644 --- a/src/Bundle/ChillTicketBundle/src/Action/Ticket/Handler/SetPersonsCommandHandler.php +++ b/src/Bundle/ChillTicketBundle/src/Action/Ticket/Handler/SetPersonsCommandHandler.php @@ -18,8 +18,8 @@ use Chill\TicketBundle\Entity\Ticket; use Chill\TicketBundle\Event\PersonsUpdateEvent; use Chill\TicketBundle\Event\TicketUpdateEvent; use Doctrine\ORM\EntityManagerInterface; +use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\Clock\ClockInterface; -use Symfony\Component\Security\Core\Security; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; final readonly class SetPersonsCommandHandler diff --git a/src/Bundle/ChillTicketBundle/src/Command/ImportTicketMotiveConfigurationCommand.php b/src/Bundle/ChillTicketBundle/src/Command/ImportTicketMotiveConfigurationCommand.php index 02808960e..e315db8ff 100644 --- a/src/Bundle/ChillTicketBundle/src/Command/ImportTicketMotiveConfigurationCommand.php +++ b/src/Bundle/ChillTicketBundle/src/Command/ImportTicketMotiveConfigurationCommand.php @@ -14,32 +14,22 @@ namespace Chill\TicketBundle\Command; use Chill\TicketBundle\Service\Import\ImportMotivesFromDirectory; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; #[AsCommand(name: 'chill:ticket:import_ticket_motive_configuration', description: 'Import ticket motives from a directory configuration.')] -class ImportTicketMotiveConfigurationCommand extends Command +final readonly class ImportTicketMotiveConfigurationCommand { - protected static $defaultName = 'chill:ticket:import_ticket_motive_configuration'; + public function __construct(private ImportMotivesFromDirectory $importMotivesFromDirectory) {} - public function __construct(private readonly ImportMotivesFromDirectory $importMotivesFromDirectory) - { - parent::__construct(); - } - - protected function configure(): void - { - $this - ->setDescription('Import ticket motives from a directory containing motives.yaml and referenced files') - ->addArgument('directory', InputArgument::REQUIRED, 'The directory path containing motives.yaml') - ->addArgument('lang', InputArgument::REQUIRED, 'The language key to use for matching labels (e.g., fr)'); - } - - protected function execute(InputInterface $input, OutputInterface $output): int - { - $directory = (string) $input->getArgument('directory'); - $lang = (string) $input->getArgument('lang'); + public function __invoke( + #[\Symfony\Component\Console\Attribute\Argument(description: 'The directory path containing motives.yaml', name: 'directory')] + string $directory, + #[\Symfony\Component\Console\Attribute\Argument(description: 'The language key to use for matching labels (e.g., fr)', name: 'lang')] + string $lang, + OutputInterface $output, + ): int { + $directory = (string) $directory; + $lang = (string) $lang; $this->importMotivesFromDirectory->import($directory, $lang); diff --git a/src/Bundle/ChillTicketBundle/src/Controller/AddCommentController.php b/src/Bundle/ChillTicketBundle/src/Controller/AddCommentController.php index 08ff93453..70fd89e89 100644 --- a/src/Bundle/ChillTicketBundle/src/Controller/AddCommentController.php +++ b/src/Bundle/ChillTicketBundle/src/Controller/AddCommentController.php @@ -16,12 +16,12 @@ use Chill\TicketBundle\Action\Ticket\Handler\AddCommentCommandHandler; use Chill\TicketBundle\Entity\Ticket; use Chill\TicketBundle\Security\Voter\CommentVoter; use Doctrine\ORM\EntityManagerInterface; +use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; -use Symfony\Component\Routing\Annotation\Route; -use Symfony\Component\Security\Core\Security; +use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; diff --git a/src/Bundle/ChillTicketBundle/src/Controller/AdminController.php b/src/Bundle/ChillTicketBundle/src/Controller/AdminController.php index 9bf5028c1..1eb890da8 100644 --- a/src/Bundle/ChillTicketBundle/src/Controller/AdminController.php +++ b/src/Bundle/ChillTicketBundle/src/Controller/AdminController.php @@ -12,7 +12,7 @@ declare(strict_types=1); namespace Chill\TicketBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Routing\Attribute\Route; /** * Class AdminController diff --git a/src/Bundle/ChillTicketBundle/src/Controller/CenterForTicketListApiController.php b/src/Bundle/ChillTicketBundle/src/Controller/CenterForTicketListApiController.php index 11b2ac961..572e796b2 100644 --- a/src/Bundle/ChillTicketBundle/src/Controller/CenterForTicketListApiController.php +++ b/src/Bundle/ChillTicketBundle/src/Controller/CenterForTicketListApiController.php @@ -14,11 +14,11 @@ namespace Chill\TicketBundle\Controller; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Security\Authorization\AuthorizationHelperForCurrentUserInterface; use Chill\PersonBundle\Security\Authorization\PersonVoter; +use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; -use Symfony\Component\Routing\Annotation\Route; -use Symfony\Component\Security\Core\Security; +use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Serializer\SerializerInterface; /** diff --git a/src/Bundle/ChillTicketBundle/src/Controller/ChangeEmergencyStateApiController.php b/src/Bundle/ChillTicketBundle/src/Controller/ChangeEmergencyStateApiController.php index 1ebc442d6..5b4003aeb 100644 --- a/src/Bundle/ChillTicketBundle/src/Controller/ChangeEmergencyStateApiController.php +++ b/src/Bundle/ChillTicketBundle/src/Controller/ChangeEmergencyStateApiController.php @@ -16,11 +16,11 @@ use Chill\TicketBundle\Action\Ticket\Handler\ChangeEmergencyStateCommandHandler; use Chill\TicketBundle\Entity\EmergencyStatusEnum; use Chill\TicketBundle\Entity\Ticket; use Doctrine\ORM\EntityManagerInterface; +use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; -use Symfony\Component\Routing\Annotation\Route; -use Symfony\Component\Security\Core\Security; +use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Serializer\SerializerInterface; /** diff --git a/src/Bundle/ChillTicketBundle/src/Controller/ChangeStateApiController.php b/src/Bundle/ChillTicketBundle/src/Controller/ChangeStateApiController.php index 55e09162d..7a69566d0 100644 --- a/src/Bundle/ChillTicketBundle/src/Controller/ChangeStateApiController.php +++ b/src/Bundle/ChillTicketBundle/src/Controller/ChangeStateApiController.php @@ -16,11 +16,11 @@ use Chill\TicketBundle\Action\Ticket\Handler\ChangeStateCommandHandler; use Chill\TicketBundle\Entity\StateEnum; use Chill\TicketBundle\Entity\Ticket; use Doctrine\ORM\EntityManagerInterface; +use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; -use Symfony\Component\Routing\Annotation\Route; -use Symfony\Component\Security\Core\Security; +use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Serializer\SerializerInterface; /** diff --git a/src/Bundle/ChillTicketBundle/src/Controller/CreateTicketController.php b/src/Bundle/ChillTicketBundle/src/Controller/CreateTicketController.php index 8e47d3afa..33f24c9a9 100644 --- a/src/Bundle/ChillTicketBundle/src/Controller/CreateTicketController.php +++ b/src/Bundle/ChillTicketBundle/src/Controller/CreateTicketController.php @@ -17,13 +17,13 @@ use Chill\TicketBundle\Action\Ticket\CreateTicketCommand; use Chill\TicketBundle\Action\Ticket\Handler\CreateTicketCommandHandler; use Chill\TicketBundle\Repository\TicketRepositoryInterface; use Doctrine\ORM\EntityManagerInterface; +use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; -use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -use Symfony\Component\Security\Core\Security; final readonly class CreateTicketController { diff --git a/src/Bundle/ChillTicketBundle/src/Controller/EditTicketController.php b/src/Bundle/ChillTicketBundle/src/Controller/EditTicketController.php index a686208ad..0d1a1ab15 100644 --- a/src/Bundle/ChillTicketBundle/src/Controller/EditTicketController.php +++ b/src/Bundle/ChillTicketBundle/src/Controller/EditTicketController.php @@ -14,7 +14,7 @@ namespace Chill\TicketBundle\Controller; use Chill\TicketBundle\Entity\Ticket; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Routing\Attribute\Route; use Twig\Environment; class EditTicketController diff --git a/src/Bundle/ChillTicketBundle/src/Controller/ReplaceMotiveController.php b/src/Bundle/ChillTicketBundle/src/Controller/ReplaceMotiveController.php index 3074ee6c1..c58b2dca0 100644 --- a/src/Bundle/ChillTicketBundle/src/Controller/ReplaceMotiveController.php +++ b/src/Bundle/ChillTicketBundle/src/Controller/ReplaceMotiveController.php @@ -15,12 +15,12 @@ use Chill\TicketBundle\Action\Ticket\Handler\ReplaceMotiveCommandHandler; use Chill\TicketBundle\Action\Ticket\ReplaceMotiveCommand; use Chill\TicketBundle\Entity\Ticket; use Doctrine\ORM\EntityManagerInterface; +use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; -use Symfony\Component\Routing\Annotation\Route; -use Symfony\Component\Security\Core\Security; +use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; diff --git a/src/Bundle/ChillTicketBundle/src/Controller/SetAddresseesController.php b/src/Bundle/ChillTicketBundle/src/Controller/SetAddresseesController.php index 9fa6dc366..2380d8aae 100644 --- a/src/Bundle/ChillTicketBundle/src/Controller/SetAddresseesController.php +++ b/src/Bundle/ChillTicketBundle/src/Controller/SetAddresseesController.php @@ -16,12 +16,12 @@ use Chill\TicketBundle\Action\Ticket\Handler\SetAddresseesCommandHandler; use Chill\TicketBundle\Action\Ticket\SetAddresseesCommand; use Chill\TicketBundle\Entity\Ticket; use Doctrine\ORM\EntityManagerInterface; +use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; -use Symfony\Component\Routing\Annotation\Route; -use Symfony\Component\Security\Core\Security; +use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; diff --git a/src/Bundle/ChillTicketBundle/src/Controller/SetCallerApiController.php b/src/Bundle/ChillTicketBundle/src/Controller/SetCallerApiController.php index 8393ca4d4..038bac488 100644 --- a/src/Bundle/ChillTicketBundle/src/Controller/SetCallerApiController.php +++ b/src/Bundle/ChillTicketBundle/src/Controller/SetCallerApiController.php @@ -15,13 +15,13 @@ use Chill\TicketBundle\Action\Ticket\SetCallerCommand; use Chill\TicketBundle\Action\Ticket\Handler\SetCallerCommandHandler; use Chill\TicketBundle\Entity\Ticket; use Doctrine\ORM\EntityManagerInterface; +use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; -use Symfony\Component\Routing\Annotation\Route; -use Symfony\Component\Security\Core\Security; +use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Serializer\SerializerInterface; /** diff --git a/src/Bundle/ChillTicketBundle/src/Controller/SetPersonsController.php b/src/Bundle/ChillTicketBundle/src/Controller/SetPersonsController.php index 3fbe254a8..c86edb602 100644 --- a/src/Bundle/ChillTicketBundle/src/Controller/SetPersonsController.php +++ b/src/Bundle/ChillTicketBundle/src/Controller/SetPersonsController.php @@ -15,12 +15,12 @@ use Chill\TicketBundle\Action\Ticket\Handler\SetPersonsCommandHandler; use Chill\TicketBundle\Action\Ticket\SetPersonsCommand; use Chill\TicketBundle\Entity\Ticket; use Doctrine\ORM\EntityManagerInterface; +use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; -use Symfony\Component\Routing\Annotation\Route; -use Symfony\Component\Security\Core\Security; +use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; diff --git a/src/Bundle/ChillTicketBundle/src/Controller/SuggestPersonForTicketApiController.php b/src/Bundle/ChillTicketBundle/src/Controller/SuggestPersonForTicketApiController.php index a71065b73..dfb524374 100644 --- a/src/Bundle/ChillTicketBundle/src/Controller/SuggestPersonForTicketApiController.php +++ b/src/Bundle/ChillTicketBundle/src/Controller/SuggestPersonForTicketApiController.php @@ -13,11 +13,11 @@ namespace Chill\TicketBundle\Controller; use Chill\TicketBundle\Entity\Ticket; use Chill\TicketBundle\Service\Ticket\SuggestPersonForTicketInterface; +use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; -use Symfony\Component\Routing\Annotation\Route; -use Symfony\Component\Security\Core\Security; +use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Serializer\SerializerInterface; final readonly class SuggestPersonForTicketApiController diff --git a/src/Bundle/ChillTicketBundle/src/Controller/TicketControllerApi.php b/src/Bundle/ChillTicketBundle/src/Controller/TicketControllerApi.php index aa9b16a59..574bd9431 100644 --- a/src/Bundle/ChillTicketBundle/src/Controller/TicketControllerApi.php +++ b/src/Bundle/ChillTicketBundle/src/Controller/TicketControllerApi.php @@ -13,7 +13,7 @@ namespace Chill\TicketBundle\Controller; use Chill\TicketBundle\Entity\Ticket; use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Serializer\SerializerInterface; class TicketControllerApi diff --git a/src/Bundle/ChillTicketBundle/src/Controller/TicketListApiController.php b/src/Bundle/ChillTicketBundle/src/Controller/TicketListApiController.php index 1a4e5ccdb..8876e642d 100644 --- a/src/Bundle/ChillTicketBundle/src/Controller/TicketListApiController.php +++ b/src/Bundle/ChillTicketBundle/src/Controller/TicketListApiController.php @@ -22,14 +22,14 @@ use Chill\TicketBundle\Entity\EmergencyStatusEnum; use Chill\TicketBundle\Entity\StateEnum; use Chill\TicketBundle\Repository\MotiveRepository; use Chill\TicketBundle\Repository\TicketACLAwareRepositoryInterface; +use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\Clock\ClockInterface; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; -use Symfony\Component\Routing\Annotation\Route; -use Symfony\Component\Security\Core\Security; +use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Serializer\SerializerInterface; final readonly class TicketListApiController diff --git a/src/Bundle/ChillTicketBundle/src/Controller/TicketListController.php b/src/Bundle/ChillTicketBundle/src/Controller/TicketListController.php index 7a25bbbc5..e495cb70a 100644 --- a/src/Bundle/ChillTicketBundle/src/Controller/TicketListController.php +++ b/src/Bundle/ChillTicketBundle/src/Controller/TicketListController.php @@ -13,11 +13,11 @@ namespace Chill\TicketBundle\Controller; use Chill\PersonBundle\Security\Authorization\PersonVoter; use Chill\PersonBundle\Entity\Person; +use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; -use Symfony\Component\Routing\Annotation\Route; -use Symfony\Component\Security\Core\Security; +use Symfony\Component\Routing\Attribute\Route; use Twig\Environment; final readonly class TicketListController diff --git a/src/Bundle/ChillTicketBundle/src/Controller/UpdateCommentController.php b/src/Bundle/ChillTicketBundle/src/Controller/UpdateCommentController.php index 5e35c534d..2fd26b7b6 100644 --- a/src/Bundle/ChillTicketBundle/src/Controller/UpdateCommentController.php +++ b/src/Bundle/ChillTicketBundle/src/Controller/UpdateCommentController.php @@ -16,12 +16,12 @@ use Chill\TicketBundle\Action\Comment\UpdateCommentContentCommand; use Chill\TicketBundle\Entity\Comment; use Chill\TicketBundle\Security\Voter\CommentVoter; use Doctrine\ORM\EntityManagerInterface; +use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; -use Symfony\Component\Routing\Annotation\Route; -use Symfony\Component\Security\Core\Security; +use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; diff --git a/src/Bundle/ChillTicketBundle/src/Controller/UpdateCommentDeletedStatusController.php b/src/Bundle/ChillTicketBundle/src/Controller/UpdateCommentDeletedStatusController.php index dcdb93a81..6f24c7c10 100644 --- a/src/Bundle/ChillTicketBundle/src/Controller/UpdateCommentDeletedStatusController.php +++ b/src/Bundle/ChillTicketBundle/src/Controller/UpdateCommentDeletedStatusController.php @@ -16,11 +16,11 @@ use Chill\TicketBundle\Action\Comment\UpdateCommentDeletedStatusCommand; use Chill\TicketBundle\Entity\Comment; use Chill\TicketBundle\Security\Voter\CommentVoter; use Doctrine\ORM\EntityManagerInterface; +use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; -use Symfony\Component\Routing\Annotation\Route; -use Symfony\Component\Security\Core\Security; +use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Serializer\SerializerInterface; final readonly class UpdateCommentDeletedStatusController diff --git a/src/Bundle/ChillTicketBundle/src/Repository/MotiveRepository.php b/src/Bundle/ChillTicketBundle/src/Repository/MotiveRepository.php index 234a7fd70..1264f410c 100644 --- a/src/Bundle/ChillTicketBundle/src/Repository/MotiveRepository.php +++ b/src/Bundle/ChillTicketBundle/src/Repository/MotiveRepository.php @@ -19,6 +19,8 @@ use Doctrine\Persistence\ManagerRegistry; /** * @template-extends ServiceEntityRepository + * + * @extends \Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository<\Chill\TicketBundle\Entity\Motive> */ class MotiveRepository extends ServiceEntityRepository implements AssociatedEntityToStoredObjectInterface { diff --git a/src/Bundle/ChillTicketBundle/src/Security/Voter/CommentVoter.php b/src/Bundle/ChillTicketBundle/src/Security/Voter/CommentVoter.php index 03622aa4b..7595fcc31 100644 --- a/src/Bundle/ChillTicketBundle/src/Security/Voter/CommentVoter.php +++ b/src/Bundle/ChillTicketBundle/src/Security/Voter/CommentVoter.php @@ -37,7 +37,7 @@ final class CommentVoter extends Voter return $subject instanceof Comment && in_array($attribute, self::ALL, true); } - protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool + protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool { /* @var Comment $subject */ return match ($attribute) { diff --git a/src/Bundle/ChillTicketBundle/src/Security/Voter/TicketVoter.php b/src/Bundle/ChillTicketBundle/src/Security/Voter/TicketVoter.php index 284dd55a8..b82fa75ae 100644 --- a/src/Bundle/ChillTicketBundle/src/Security/Voter/TicketVoter.php +++ b/src/Bundle/ChillTicketBundle/src/Security/Voter/TicketVoter.php @@ -30,7 +30,7 @@ final class TicketVoter extends Voter return $subject instanceof Ticket && in_array($attribute, self::ALL, true); } - protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool + protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token, ?\Symfony\Component\Security\Core\Authorization\Voter\Vote $vote = null): bool { return true; } diff --git a/src/Bundle/ChillTicketBundle/src/Serializer/Normalizer/SetAddresseesCommandDenormalizer.php b/src/Bundle/ChillTicketBundle/src/Serializer/Normalizer/SetAddresseesCommandDenormalizer.php index 86a843cd5..a6795c545 100644 --- a/src/Bundle/ChillTicketBundle/src/Serializer/Normalizer/SetAddresseesCommandDenormalizer.php +++ b/src/Bundle/ChillTicketBundle/src/Serializer/Normalizer/SetAddresseesCommandDenormalizer.php @@ -23,7 +23,7 @@ final class SetAddresseesCommandDenormalizer implements DenormalizerInterface, D { use DenormalizerAwareTrait; - public function denormalize($data, string $type, ?string $format = null, array $context = []) + public function denormalize($data, string $type, ?string $format = null, array $context = []): ?SetAddresseesCommand { if (null === $data) { return null; @@ -49,8 +49,13 @@ final class SetAddresseesCommandDenormalizer implements DenormalizerInterface, D return new SetAddresseesCommand($addresses); } - public function supportsDenormalization($data, string $type, ?string $format = null) + public function supportsDenormalization($data, string $type, ?string $format = null, array $context = []): bool { return SetAddresseesCommand::class === $type && 'json' === $format; } + + public function getSupportedTypes(?string $format): array + { + return 'json' === $format ? [SetAddresseesCommand::class => false] : []; + } } diff --git a/src/Bundle/ChillTicketBundle/src/Serializer/Normalizer/SetPersonsCommandDenormalizer.php b/src/Bundle/ChillTicketBundle/src/Serializer/Normalizer/SetPersonsCommandDenormalizer.php index b0b29cbf7..bbffdedd6 100644 --- a/src/Bundle/ChillTicketBundle/src/Serializer/Normalizer/SetPersonsCommandDenormalizer.php +++ b/src/Bundle/ChillTicketBundle/src/Serializer/Normalizer/SetPersonsCommandDenormalizer.php @@ -22,7 +22,7 @@ class SetPersonsCommandDenormalizer implements DenormalizerInterface, Denormaliz { use DenormalizerAwareTrait; - public function denormalize($data, string $type, ?string $format = null, array $context = []) + public function denormalize($data, string $type, ?string $format = null, array $context = []): ?SetPersonsCommand { if (null === $data) { return null; @@ -44,8 +44,13 @@ class SetPersonsCommandDenormalizer implements DenormalizerInterface, Denormaliz return new SetPersonsCommand($persons); } - public function supportsDenormalization($data, string $type, ?string $format = null) + public function supportsDenormalization($data, string $type, ?string $format = null, array $context = []): bool { return SetPersonsCommand::class === $type; } + + public function getSupportedTypes(?string $format): array + { + return 'json' === $format ? [SetPersonsCommand::class => false] : []; + } } diff --git a/src/Bundle/ChillTicketBundle/src/Serializer/Normalizer/TicketNormalizer.php b/src/Bundle/ChillTicketBundle/src/Serializer/Normalizer/TicketNormalizer.php index 30b057f21..8a45e09a4 100644 --- a/src/Bundle/ChillTicketBundle/src/Serializer/Normalizer/TicketNormalizer.php +++ b/src/Bundle/ChillTicketBundle/src/Serializer/Normalizer/TicketNormalizer.php @@ -23,7 +23,7 @@ use Chill\TicketBundle\Entity\PersonHistory; use Chill\TicketBundle\Entity\StateHistory; use Chill\TicketBundle\Entity\Ticket; use Chill\TicketBundle\Security\Voter\CommentVoter; -use Symfony\Component\Security\Core\Security; +use Symfony\Bundle\SecurityBundle\Security; use Symfony\Component\Serializer\Exception\UnexpectedValueException; use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait; @@ -35,7 +35,7 @@ final class TicketNormalizer implements NormalizerInterface, NormalizerAwareInte public function __construct(private Security $security) {} - public function normalize($object, ?string $format = null, array $context = []) + public function normalize($object, ?string $format = null, array $context = []): array { if (!$object instanceof Ticket) { throw new UnexpectedValueException(); @@ -74,7 +74,7 @@ final class TicketNormalizer implements NormalizerInterface, NormalizerAwareInte return $data; } - public function supportsNormalization($data, ?string $format = null) + public function supportsNormalization($data, ?string $format = null, array $context = []): bool { return 'json' === $format && $data instanceof Ticket; } @@ -280,4 +280,9 @@ final class TicketNormalizer implements NormalizerInterface, NormalizerAwareInte return $steps; } + + public function getSupportedTypes(?string $format): array + { + return 'json' === $format ? [Ticket::class => false] : []; + } } diff --git a/src/Bundle/ChillTicketBundle/src/config/routes.yaml b/src/Bundle/ChillTicketBundle/src/config/routes.yaml index 9823744ea..dd61a1460 100644 --- a/src/Bundle/ChillTicketBundle/src/config/routes.yaml +++ b/src/Bundle/ChillTicketBundle/src/config/routes.yaml @@ -1,3 +1,3 @@ chill_ticket_controller: resource: '@ChillTicketBundle/Controller/' - type: annotation + type: attribute diff --git a/src/Bundle/ChillTicketBundle/tests/Service/Import/ImportMotivesFromDirectoryTest.php b/src/Bundle/ChillTicketBundle/tests/Service/Import/ImportMotivesFromDirectoryTest.php index 8939940b7..dd1137ab9 100644 --- a/src/Bundle/ChillTicketBundle/tests/Service/Import/ImportMotivesFromDirectoryTest.php +++ b/src/Bundle/ChillTicketBundle/tests/Service/Import/ImportMotivesFromDirectoryTest.php @@ -61,7 +61,7 @@ YAML; $emProphecy->persist(Argument::type(StoredObject::class))->shouldBeCalled(); $capturedMotive = null; $emProphecy->persist(Argument::type(Motive::class)) - ->will(function ($args) use (&$capturedMotive) { + ->will(function ($args) use (&$capturedMotive): void { $capturedMotive = $args[0]; }) ->shouldBeCalled(); @@ -121,7 +121,7 @@ YAML; $persistedMotives = []; $emProphecy = $this->prophesize(EntityManagerInterface::class); $emProphecy->persist(Argument::type(Motive::class)) - ->will(function ($args) use (&$persistedMotives) { + ->will(function ($args) use (&$persistedMotives): void { $persistedMotives[] = $args[0]; }) ->shouldBeCalled(); @@ -195,7 +195,7 @@ YAML; $persistedMotives = []; $emProphecy = $this->prophesize(EntityManagerInterface::class); $emProphecy->persist(Argument::type(Motive::class)) - ->will(function ($args) use (&$persistedMotives) { + ->will(function ($args) use (&$persistedMotives): void { $persistedMotives[] = $args[0]; }) ->shouldBeCalled();