From 15588985fb28f6c2a334a267a99c6773a056dde7 Mon Sep 17 00:00:00 2001 From: Dumazeau Date: Tue, 25 Apr 2023 17:58:19 +0200 Subject: [PATCH] Transform autorieation to Voter --- src/Domain/UseCase/IsAnAuthorizedIp.php | 2 +- src/Infrastructure/FormType/MaintenanceFormType.php | 1 - src/Infrastructure/Voter/MaintenanceAdministrationVoter.php | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Domain/UseCase/IsAnAuthorizedIp.php b/src/Domain/UseCase/IsAnAuthorizedIp.php index ae6f048..d5f83c5 100644 --- a/src/Domain/UseCase/IsAnAuthorizedIp.php +++ b/src/Domain/UseCase/IsAnAuthorizedIp.php @@ -14,7 +14,7 @@ class IsAnAuthorizedIp public function __construct(ParameterBagInterface $parameterBag) { - $this->ipAddresses = $parameterBag->get('lexik_maintenance.authorized.ips'); + $this->ipAddresses = (array) $parameterBag->get('lexik_maintenance.authorized.ips'); } public function __invoke(string $ip): bool diff --git a/src/Infrastructure/FormType/MaintenanceFormType.php b/src/Infrastructure/FormType/MaintenanceFormType.php index 375decd..f8dc1c2 100644 --- a/src/Infrastructure/FormType/MaintenanceFormType.php +++ b/src/Infrastructure/FormType/MaintenanceFormType.php @@ -13,7 +13,6 @@ class MaintenanceFormType extends AbstractType { - /* @phpstan-ignore-next-line */ public function buildForm(FormBuilderInterface $builder, array $options): void { $builder diff --git a/src/Infrastructure/Voter/MaintenanceAdministrationVoter.php b/src/Infrastructure/Voter/MaintenanceAdministrationVoter.php index 8a8dacc..3771bff 100644 --- a/src/Infrastructure/Voter/MaintenanceAdministrationVoter.php +++ b/src/Infrastructure/Voter/MaintenanceAdministrationVoter.php @@ -20,12 +20,12 @@ public function __construct(HasAccessToAdministration $hasAccessToAdministration $this->hasAccessToAdministration = $hasAccessToAdministration; } - protected function supports($attribute, $subject) + protected function supports(string $attribute, $subject) { return \in_array($attribute, [self::EDIT_ADMINISTRATION_MAINTENANCE], true); } - protected function voteOnAttribute($attribute, $subject, TokenInterface $token) + protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token) { switch ($attribute) { case self::EDIT_ADMINISTRATION_MAINTENANCE: