diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityRepository.php index 4942eef16..ff4904f9e 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityRepository.php @@ -17,8 +17,6 @@ use Chill\DocStoreBundle\Repository\AssociatedEntityToStoredObjectInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; -use Doctrine\ORM\NonUniqueResultException; -use Doctrine\ORM\NoResultException; use Doctrine\Persistence\ManagerRegistry; /** diff --git a/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityStoredObjectVoter.php b/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityStoredObjectVoter.php index 01ec68bd9..be3013a08 100644 --- a/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityStoredObjectVoter.php +++ b/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityStoredObjectVoter.php @@ -1,11 +1,18 @@ repository; } - /** - * @inheritDoc - */ protected function getClass(): string { return Activity::class; diff --git a/src/Bundle/ChillDocStoreBundle/Repository/AccompanyingCourseDocumentRepository.php b/src/Bundle/ChillDocStoreBundle/Repository/AccompanyingCourseDocumentRepository.php index 744afd424..7033a53c9 100644 --- a/src/Bundle/ChillDocStoreBundle/Repository/AccompanyingCourseDocumentRepository.php +++ b/src/Bundle/ChillDocStoreBundle/Repository/AccompanyingCourseDocumentRepository.php @@ -80,5 +80,4 @@ class AccompanyingCourseDocumentRepository implements ObjectRepository, Associat { return AccompanyingCourseDocument::class; } - } diff --git a/src/Bundle/ChillDocStoreBundle/Repository/AssociatedEntityToStoredObjectInterface.php b/src/Bundle/ChillDocStoreBundle/Repository/AssociatedEntityToStoredObjectInterface.php index 5349251c5..81d230e67 100644 --- a/src/Bundle/ChillDocStoreBundle/Repository/AssociatedEntityToStoredObjectInterface.php +++ b/src/Bundle/ChillDocStoreBundle/Repository/AssociatedEntityToStoredObjectInterface.php @@ -1,5 +1,14 @@ storedObjectRepository->findOneBy(['filename' => $subject->object_name]); - return match($subject->method) { + return match ($subject->method) { 'GET' => $this->security->isGranted(StoredObjectRoleEnum::SEE->value, $storedObject), 'PUT' => $this->security->isGranted(StoredObjectRoleEnum::EDIT->value, $storedObject), default => $this->security->isGranted('ROLE_USER') || $this->security->isGranted('ROLE_ADMIN') diff --git a/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoter.php b/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoter.php index 57688e05b..c0851144a 100644 --- a/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoter.php +++ b/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoter.php @@ -24,9 +24,7 @@ use Symfony\Component\Security\Core\Security; */ class StoredObjectVoter extends Voter { - - public function __construct(private readonly Security $security, private readonly iterable $storedObjectVoters) { - } + public function __construct(private readonly Security $security, private readonly iterable $storedObjectVoters) {} protected function supports($attribute, $subject): bool { diff --git a/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoterInterface.php b/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoterInterface.php index 516722654..97d45eec3 100644 --- a/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoterInterface.php +++ b/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoterInterface.php @@ -12,13 +12,11 @@ declare(strict_types=1); namespace Chill\DocStoreBundle\Security\Authorization; use Chill\DocStoreBundle\Entity\StoredObject; -use Chill\DocStoreBundle\Security\Authorization\StoredObjectRoleEnum; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; -interface StoredObjectVoterInterface { - +interface StoredObjectVoterInterface +{ public function supports(StoredObjectRoleEnum $attribute, StoredObject $subject): bool; public function voteOnAttribute(StoredObjectRoleEnum $attribute, StoredObject $subject, TokenInterface $token): bool; - } diff --git a/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoters/AbstractStoredObjectVoter.php b/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoters/AbstractStoredObjectVoter.php index 659d7d28a..24def7ca9 100644 --- a/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoters/AbstractStoredObjectVoter.php +++ b/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoters/AbstractStoredObjectVoter.php @@ -1,14 +1,21 @@ getClass(); + return $this->getRepository()->findAssociatedEntityToStoredObject($subject) instanceof $class; } @@ -52,7 +58,7 @@ abstract class AbstractStoredObjectVoter implements StoredObjectVoterInterface if ($this->canBeAssociatedWithWorkflow()) { if (null === $this->workflowDocumentService) { - throw new \LogicException("Provide a workflow document service"); + throw new \LogicException('Provide a workflow document service'); } return $this->workflowDocumentService->notBlockedByWorkflow($entity); diff --git a/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoters/AccompanyingCourseDocumentStoredObjectVoter.php b/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoters/AccompanyingCourseDocumentStoredObjectVoter.php index 86e7bd9de..2665553e8 100644 --- a/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoters/AccompanyingCourseDocumentStoredObjectVoter.php +++ b/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoters/AccompanyingCourseDocumentStoredObjectVoter.php @@ -1,5 +1,14 @@ repository; } - /** - * @inheritDoc - */ protected function getClass(): string { return AccompanyingPeriodWork::class; diff --git a/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoters/ActivityStoredObjectVoter.php b/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoters/ActivityStoredObjectVoter.php index a36535005..4f897b36c 100644 --- a/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoters/ActivityStoredObjectVoter.php +++ b/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoters/ActivityStoredObjectVoter.php @@ -1,9 +1,17 @@ repository; } - /** - * @inheritDoc - */ protected function getClass(): string { return Activity::class; diff --git a/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoters/EventStoredObjectVoter.php b/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoters/EventStoredObjectVoter.php index 218ce1980..d258b3ae3 100644 --- a/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoters/EventStoredObjectVoter.php +++ b/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoters/EventStoredObjectVoter.php @@ -1,5 +1,14 @@ repository; } - /** - * @inheritDoc - */ protected function getClass(): string { return Event::class; diff --git a/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoters/PersonDocumentStoredObjectVoter.php b/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoters/PersonDocumentStoredObjectVoter.php index a40d08849..5791d724b 100644 --- a/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoters/PersonDocumentStoredObjectVoter.php +++ b/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoters/PersonDocumentStoredObjectVoter.php @@ -1,5 +1,14 @@ repository; } - /** - * @inheritDoc - */ protected function getClass(): string { return PersonDocument::class; diff --git a/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoters/PersonStoredObjectVoter.php b/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoters/PersonStoredObjectVoter.php index 6c3b0b807..4d8a1220f 100644 --- a/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoters/PersonStoredObjectVoter.php +++ b/src/Bundle/ChillDocStoreBundle/Security/Authorization/StoredObjectVoters/PersonStoredObjectVoter.php @@ -1,5 +1,14 @@ repository; } - /** - * @inheritDoc - */ protected function getClass(): string { return PersonDocument::class; diff --git a/src/Bundle/ChillDocStoreBundle/Service/WorkflowDocumentService.php b/src/Bundle/ChillDocStoreBundle/Service/WorkflowDocumentService.php index a279912a9..78c7b7b7d 100644 --- a/src/Bundle/ChillDocStoreBundle/Service/WorkflowDocumentService.php +++ b/src/Bundle/ChillDocStoreBundle/Service/WorkflowDocumentService.php @@ -1,18 +1,23 @@ entityWorkflowManager->findByRelatedEntity($entity); $currentUser = $this->security->getUser(); - if (null != $workflow) { if ($workflow->isFinal()) { return false; @@ -35,5 +39,4 @@ class WorkflowDocumentService return true; } - } diff --git a/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php b/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php index d1a384ef3..74e51b19e 100644 --- a/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php +++ b/src/Bundle/ChillDocStoreBundle/Workflow/AccompanyingCourseDocumentWorkflowHandler.php @@ -18,19 +18,15 @@ use Chill\MainBundle\Entity\Workflow\EntityWorkflow; use Chill\MainBundle\Repository\Workflow\EntityWorkflowRepository; use Chill\MainBundle\Workflow\EntityWorkflowHandlerInterface; use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation; -use Doctrine\ORM\EntityManagerInterface; -use Doctrine\ORM\EntityRepository; use Symfony\Contracts\Translation\TranslatorInterface; readonly class AccompanyingCourseDocumentWorkflowHandler implements EntityWorkflowHandlerInterface { - public function __construct( - private TranslatorInterface $translator, - private EntityWorkflowRepository $workflowRepository, + private TranslatorInterface $translator, + private EntityWorkflowRepository $workflowRepository, private AccompanyingCourseDocumentRepository $repository - ) { - } + ) {} public function getDeletionRoles(): array { @@ -127,7 +123,7 @@ readonly class AccompanyingCourseDocumentWorkflowHandler implements EntityWorkfl public function findByRelatedEntity(object $object): ?EntityWorkflow { - if(!$object instanceof AccompanyingCourseDocument) { + if (!$object instanceof AccompanyingCourseDocument) { return null; } diff --git a/src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php b/src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php index 19829a369..3fe305ff7 100644 --- a/src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php +++ b/src/Bundle/ChillEventBundle/Form/ChoiceLoader/EventChoiceLoader.php @@ -13,7 +13,6 @@ namespace Chill\EventBundle\Form\ChoiceLoader; use Chill\EventBundle\Entity\Event; use Chill\EventBundle\Repository\EventRepository; -use Doctrine\ORM\EntityRepository; use Symfony\Component\Form\ChoiceList\ChoiceListInterface; use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface; diff --git a/src/Bundle/ChillEventBundle/Repository/EventRepository.php b/src/Bundle/ChillEventBundle/Repository/EventRepository.php index 03ee366ac..89723b770 100644 --- a/src/Bundle/ChillEventBundle/Repository/EventRepository.php +++ b/src/Bundle/ChillEventBundle/Repository/EventRepository.php @@ -16,8 +16,6 @@ use Chill\DocStoreBundle\Repository\AssociatedEntityToStoredObjectInterface; use Chill\EventBundle\Entity\Event; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; -use Doctrine\ORM\NonUniqueResultException; -use Doctrine\ORM\NoResultException; use Doctrine\ORM\QueryBuilder; use Doctrine\Persistence\ObjectRepository; diff --git a/src/Bundle/ChillEventBundle/Security/Authorization/EventStoredObjectVoter.php b/src/Bundle/ChillEventBundle/Security/Authorization/EventStoredObjectVoter.php index 9db6177c8..8dda94aad 100644 --- a/src/Bundle/ChillEventBundle/Security/Authorization/EventStoredObjectVoter.php +++ b/src/Bundle/ChillEventBundle/Security/Authorization/EventStoredObjectVoter.php @@ -1,5 +1,14 @@ repository; } - /** - * @inheritDoc - */ protected function getClass(): string { return Event::class; diff --git a/src/Bundle/ChillMainBundle/Repository/Workflow/EntityWorkflowRepository.php b/src/Bundle/ChillMainBundle/Repository/Workflow/EntityWorkflowRepository.php index 7d2e047d3..dba68ee41 100644 --- a/src/Bundle/ChillMainBundle/Repository/Workflow/EntityWorkflowRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/Workflow/EntityWorkflowRepository.php @@ -112,7 +112,6 @@ class EntityWorkflowRepository implements ObjectRepository ->setParameter('entity_id', $relatedEntityId); return $query->getQuery()->getResult(); - } /** diff --git a/src/Bundle/ChillMainBundle/Workflow/EntityWorkflowManager.php b/src/Bundle/ChillMainBundle/Workflow/EntityWorkflowManager.php index 3f2ff0439..26c31506f 100644 --- a/src/Bundle/ChillMainBundle/Workflow/EntityWorkflowManager.php +++ b/src/Bundle/ChillMainBundle/Workflow/EntityWorkflowManager.php @@ -43,7 +43,7 @@ class EntityWorkflowManager foreach ($this->handlers as $handler) { return $handler->findByRelatedEntity($object); } + return null; } - } diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkEvaluationDocumentVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkEvaluationDocumentVoter.php index ecf3cd802..97ca84a13 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkEvaluationDocumentVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodWorkEvaluationDocumentVoter.php @@ -11,7 +11,6 @@ declare(strict_types=1); namespace Chill\PersonBundle\Security\Authorization; -use Chill\DocStoreBundle\Security\Authorization\StoredObjectVoterInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface; diff --git a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php index 0fd3af0af..34f8db4a7 100644 --- a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php +++ b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler.php @@ -140,6 +140,7 @@ class AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler implements EntityW if (!$object instanceof AccompanyingPeriodWorkEvaluationDocument) { return null; } + return $this->workflowRepository->findByRelatedEntity(AccompanyingPeriodWorkEvaluationDocument::class, $object->getId()); } } diff --git a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php index 81116b7b2..d40080e33 100644 --- a/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php +++ b/src/Bundle/ChillPersonBundle/Workflow/AccompanyingPeriodWorkWorkflowHandler.php @@ -133,6 +133,7 @@ class AccompanyingPeriodWorkWorkflowHandler implements EntityWorkflowHandlerInte if (!$object instanceof AccompanyingPeriodWork) { return null; } + return $this->workflowRepository->findByRelatedEntity(AccompanyingPeriodWork::class, $object->getId()); } } diff --git a/src/Bundle/ChillWopiBundle/src/Service/Wopi/AuthorizationManager.php b/src/Bundle/ChillWopiBundle/src/Service/Wopi/AuthorizationManager.php index d773a8eb4..4c9cb4a2f 100644 --- a/src/Bundle/ChillWopiBundle/src/Service/Wopi/AuthorizationManager.php +++ b/src/Bundle/ChillWopiBundle/src/Service/Wopi/AuthorizationManager.php @@ -12,7 +12,6 @@ declare(strict_types=1); namespace Chill\WopiBundle\Service\Wopi; use ChampsLibres\WopiLib\Contract\Entity\Document; - use Chill\DocStoreBundle\Repository\StoredObjectRepository; use Chill\DocStoreBundle\Security\Authorization\StoredObjectRoleEnum; use Chill\MainBundle\Entity\User; @@ -70,7 +69,6 @@ class AuthorizationManager implements \ChampsLibres\WopiBundle\Contracts\Authori { $storedObject = $this->getRelatedStoredObject($document); if ($this->security->isGranted(StoredObjectRoleEnum::SEE->value, $storedObject)) { - return $this->isTokenValid($accessToken, $document, $request); } @@ -103,5 +101,4 @@ class AuthorizationManager implements \ChampsLibres\WopiBundle\Contracts\Authori return false; } - }