Php cs fixes

This commit is contained in:
Julie Lenaerts 2024-07-04 11:39:02 +02:00
parent 428494ca1f
commit 21b79c1981
26 changed files with 133 additions and 80 deletions

View File

@ -17,8 +17,6 @@ use Chill\DocStoreBundle\Repository\AssociatedEntityToStoredObjectInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\NonUniqueResultException;
use Doctrine\ORM\NoResultException;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\Persistence\ManagerRegistry;
/** /**

View File

@ -1,11 +1,18 @@
<?php <?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ActivityBundle\Security\Authorization; namespace Chill\ActivityBundle\Security\Authorization;
use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Repository\ActivityDocumentACLAwareRepository;
use Chill\ActivityBundle\Repository\ActivityRepository; use Chill\ActivityBundle\Repository\ActivityRepository;
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
use Chill\DocStoreBundle\Repository\AssociatedEntityToStoredObjectInterface; use Chill\DocStoreBundle\Repository\AssociatedEntityToStoredObjectInterface;
use Chill\DocStoreBundle\Security\Authorization\StoredObjectRoleEnum; use Chill\DocStoreBundle\Security\Authorization\StoredObjectRoleEnum;
use Chill\DocStoreBundle\Security\Authorization\StoredObjectVoters\AbstractStoredObjectVoter; use Chill\DocStoreBundle\Security\Authorization\StoredObjectVoters\AbstractStoredObjectVoter;
@ -18,7 +25,7 @@ class ActivityStoredObjectVoter extends AbstractStoredObjectVoter
private readonly ActivityRepository $repository, private readonly ActivityRepository $repository,
Security $security, Security $security,
WorkflowDocumentService $workflowDocumentService WorkflowDocumentService $workflowDocumentService
){ ) {
parent::__construct($security, $workflowDocumentService); parent::__construct($security, $workflowDocumentService);
} }
@ -27,9 +34,6 @@ class ActivityStoredObjectVoter extends AbstractStoredObjectVoter
return $this->repository; return $this->repository;
} }
/**
* @inheritDoc
*/
protected function getClass(): string protected function getClass(): string
{ {
return Activity::class; return Activity::class;

View File

@ -80,5 +80,4 @@ class AccompanyingCourseDocumentRepository implements ObjectRepository, Associat
{ {
return AccompanyingCourseDocument::class; return AccompanyingCourseDocument::class;
} }
} }

View File

@ -1,5 +1,14 @@
<?php <?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\DocStoreBundle\Repository; namespace Chill\DocStoreBundle\Repository;
use Chill\DocStoreBundle\Entity\StoredObject; use Chill\DocStoreBundle\Entity\StoredObject;

View File

@ -12,7 +12,6 @@ declare(strict_types=1);
namespace Chill\DocStoreBundle\Security\Authorization; namespace Chill\DocStoreBundle\Security\Authorization;
use Chill\DocStoreBundle\AsyncUpload\SignedUrl; use Chill\DocStoreBundle\AsyncUpload\SignedUrl;
use Chill\DocStoreBundle\Entity\StoredObject;
use Chill\DocStoreBundle\Repository\StoredObjectRepository; use Chill\DocStoreBundle\Repository\StoredObjectRepository;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter; use Symfony\Component\Security\Core\Authorization\Voter\Voter;
@ -41,7 +40,7 @@ final class AsyncUploadVoter extends Voter
$storedObject = $this->storedObjectRepository->findOneBy(['filename' => $subject->object_name]); $storedObject = $this->storedObjectRepository->findOneBy(['filename' => $subject->object_name]);
return match($subject->method) { return match ($subject->method) {
'GET' => $this->security->isGranted(StoredObjectRoleEnum::SEE->value, $storedObject), 'GET' => $this->security->isGranted(StoredObjectRoleEnum::SEE->value, $storedObject),
'PUT' => $this->security->isGranted(StoredObjectRoleEnum::EDIT->value, $storedObject), 'PUT' => $this->security->isGranted(StoredObjectRoleEnum::EDIT->value, $storedObject),
default => $this->security->isGranted('ROLE_USER') || $this->security->isGranted('ROLE_ADMIN') default => $this->security->isGranted('ROLE_USER') || $this->security->isGranted('ROLE_ADMIN')

View File

@ -24,9 +24,7 @@ use Symfony\Component\Security\Core\Security;
*/ */
class StoredObjectVoter extends Voter 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 protected function supports($attribute, $subject): bool
{ {

View File

@ -12,13 +12,11 @@ declare(strict_types=1);
namespace Chill\DocStoreBundle\Security\Authorization; namespace Chill\DocStoreBundle\Security\Authorization;
use Chill\DocStoreBundle\Entity\StoredObject; use Chill\DocStoreBundle\Entity\StoredObject;
use Chill\DocStoreBundle\Security\Authorization\StoredObjectRoleEnum;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
interface StoredObjectVoterInterface { interface StoredObjectVoterInterface
{
public function supports(StoredObjectRoleEnum $attribute, StoredObject $subject): bool; public function supports(StoredObjectRoleEnum $attribute, StoredObject $subject): bool;
public function voteOnAttribute(StoredObjectRoleEnum $attribute, StoredObject $subject, TokenInterface $token): bool; public function voteOnAttribute(StoredObjectRoleEnum $attribute, StoredObject $subject, TokenInterface $token): bool;
} }

View File

@ -1,14 +1,21 @@
<?php <?php
namespace Chill\DocStoreBundle\Security\Authorization\StoredObjectVoters; declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\DocStoreBundle\Security\Authorization\StoredObjectVoters;
use Chill\DocStoreBundle\Entity\StoredObject; use Chill\DocStoreBundle\Entity\StoredObject;
use Chill\DocStoreBundle\Repository\AssociatedEntityToStoredObjectInterface; use Chill\DocStoreBundle\Repository\AssociatedEntityToStoredObjectInterface;
use Chill\DocStoreBundle\Security\Authorization\StoredObjectRoleEnum; use Chill\DocStoreBundle\Security\Authorization\StoredObjectRoleEnum;
use Chill\DocStoreBundle\Security\Authorization\StoredObjectVoterInterface; use Chill\DocStoreBundle\Security\Authorization\StoredObjectVoterInterface;
use Chill\DocStoreBundle\Service\WorkflowDocumentService; use Chill\DocStoreBundle\Service\WorkflowDocumentService;
use Chill\MainBundle\Entity\User;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Core\Security;
@ -25,16 +32,15 @@ abstract class AbstractStoredObjectVoter implements StoredObjectVoterInterface
abstract protected function canBeAssociatedWithWorkflow(): bool; abstract protected function canBeAssociatedWithWorkflow(): bool;
function __construct( public function __construct(
private readonly Security $security, private readonly Security $security,
private readonly ?WorkflowDocumentService $workflowDocumentService = null, private readonly ?WorkflowDocumentService $workflowDocumentService = null,
) ) {}
{
}
public function supports(StoredObjectRoleEnum $attribute, StoredObject $subject): bool public function supports(StoredObjectRoleEnum $attribute, StoredObject $subject): bool
{ {
$class = $this->getClass(); $class = $this->getClass();
return $this->getRepository()->findAssociatedEntityToStoredObject($subject) instanceof $class; return $this->getRepository()->findAssociatedEntityToStoredObject($subject) instanceof $class;
} }
@ -52,7 +58,7 @@ abstract class AbstractStoredObjectVoter implements StoredObjectVoterInterface
if ($this->canBeAssociatedWithWorkflow()) { if ($this->canBeAssociatedWithWorkflow()) {
if (null === $this->workflowDocumentService) { 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); return $this->workflowDocumentService->notBlockedByWorkflow($entity);

View File

@ -1,5 +1,14 @@
<?php <?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\DocStoreBundle\Security\Authorization\StoredObjectVoters; namespace Chill\DocStoreBundle\Security\Authorization\StoredObjectVoters;
use Chill\DocStoreBundle\Entity\AccompanyingCourseDocument; use Chill\DocStoreBundle\Entity\AccompanyingCourseDocument;
@ -7,7 +16,6 @@ use Chill\DocStoreBundle\Repository\AccompanyingCourseDocumentRepository;
use Chill\DocStoreBundle\Repository\AssociatedEntityToStoredObjectInterface; use Chill\DocStoreBundle\Repository\AssociatedEntityToStoredObjectInterface;
use Chill\DocStoreBundle\Security\Authorization\AccompanyingCourseDocumentVoter; use Chill\DocStoreBundle\Security\Authorization\AccompanyingCourseDocumentVoter;
use Chill\DocStoreBundle\Security\Authorization\StoredObjectRoleEnum; use Chill\DocStoreBundle\Security\Authorization\StoredObjectRoleEnum;
use Chill\DocStoreBundle\Security\Authorization\StoredObjectVoters\AbstractStoredObjectVoter;
use Chill\DocStoreBundle\Service\WorkflowDocumentService; use Chill\DocStoreBundle\Service\WorkflowDocumentService;
use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Core\Security;
@ -17,7 +25,7 @@ final class AccompanyingCourseDocumentStoredObjectVoter extends AbstractStoredOb
private readonly AccompanyingCourseDocumentRepository $repository, private readonly AccompanyingCourseDocumentRepository $repository,
Security $security, Security $security,
WorkflowDocumentService $workflowDocumentService WorkflowDocumentService $workflowDocumentService
){ ) {
parent::__construct($security, $workflowDocumentService); parent::__construct($security, $workflowDocumentService);
} }

View File

@ -1,5 +1,14 @@
<?php <?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace ChillDocStoreBundle\Security\Authorization\StoredObjectVoters; namespace ChillDocStoreBundle\Security\Authorization\StoredObjectVoters;
use Chill\DocStoreBundle\Entity\AccompanyingCourseDocument; use Chill\DocStoreBundle\Entity\AccompanyingCourseDocument;
@ -17,7 +26,7 @@ final class AccompanyingCourseStoredObjectVoter extends AbstractStoredObjectVote
private readonly AccompanyingCourseDocumentRepository $repository, private readonly AccompanyingCourseDocumentRepository $repository,
Security $security, Security $security,
WorkflowDocumentService $workflowDocumentService WorkflowDocumentService $workflowDocumentService
){ ) {
parent::__construct($security, $workflowDocumentService); parent::__construct($security, $workflowDocumentService);
} }

View File

@ -1,5 +1,14 @@
<?php <?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\DocStoreBundle\Security\Authorization\StoredObjectVoters; namespace Chill\DocStoreBundle\Security\Authorization\StoredObjectVoters;
use Chill\DocStoreBundle\Repository\AssociatedEntityToStoredObjectInterface; use Chill\DocStoreBundle\Repository\AssociatedEntityToStoredObjectInterface;
@ -8,7 +17,6 @@ use Chill\DocStoreBundle\Service\WorkflowDocumentService;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository; use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodWorkVoter; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodWorkVoter;
use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Core\Security;
class AccompanyingPeriodWorkEvaluationStoredObjectVoter extends AbstractStoredObjectVoter class AccompanyingPeriodWorkEvaluationStoredObjectVoter extends AbstractStoredObjectVoter
@ -17,7 +25,7 @@ class AccompanyingPeriodWorkEvaluationStoredObjectVoter extends AbstractStoredOb
private readonly AccompanyingPeriodWorkRepository $repository, private readonly AccompanyingPeriodWorkRepository $repository,
Security $security, Security $security,
WorkflowDocumentService $workflowDocumentService WorkflowDocumentService $workflowDocumentService
){ ) {
parent::__construct($security, $workflowDocumentService); parent::__construct($security, $workflowDocumentService);
} }
@ -26,9 +34,6 @@ class AccompanyingPeriodWorkEvaluationStoredObjectVoter extends AbstractStoredOb
return $this->repository; return $this->repository;
} }
/**
* @inheritDoc
*/
protected function getClass(): string protected function getClass(): string
{ {
return AccompanyingPeriodWork::class; return AccompanyingPeriodWork::class;

View File

@ -1,9 +1,17 @@
<?php <?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace src\Bundle\ChillDocStoreBundle\Security\Authorization\StoredObjectVoters; namespace src\Bundle\ChillDocStoreBundle\Security\Authorization\StoredObjectVoters;
use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Repository\ActivityDocumentACLAwareRepository;
use Chill\ActivityBundle\Repository\ActivityRepository; use Chill\ActivityBundle\Repository\ActivityRepository;
use Chill\ActivityBundle\Security\Authorization\ActivityVoter; use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
use Chill\DocStoreBundle\Repository\AssociatedEntityToStoredObjectInterface; use Chill\DocStoreBundle\Repository\AssociatedEntityToStoredObjectInterface;
@ -18,7 +26,7 @@ class ActivityStoredObjectVoter extends AbstractStoredObjectVoter
private readonly ActivityRepository $repository, private readonly ActivityRepository $repository,
Security $security, Security $security,
WorkflowDocumentService $workflowDocumentService WorkflowDocumentService $workflowDocumentService
){ ) {
parent::__construct($security, $workflowDocumentService); parent::__construct($security, $workflowDocumentService);
} }
@ -27,9 +35,6 @@ class ActivityStoredObjectVoter extends AbstractStoredObjectVoter
return $this->repository; return $this->repository;
} }
/**
* @inheritDoc
*/
protected function getClass(): string protected function getClass(): string
{ {
return Activity::class; return Activity::class;

View File

@ -1,5 +1,14 @@
<?php <?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace src\Bundle\ChillDocStoreBundle\Security\Authorization\StoredObjectVoters; namespace src\Bundle\ChillDocStoreBundle\Security\Authorization\StoredObjectVoters;
use Chill\DocStoreBundle\Repository\AssociatedEntityToStoredObjectInterface; use Chill\DocStoreBundle\Repository\AssociatedEntityToStoredObjectInterface;
@ -17,7 +26,7 @@ class EventStoredObjectVoter extends AbstractStoredObjectVoter
private readonly EventRepository $repository, private readonly EventRepository $repository,
Security $security, Security $security,
WorkflowDocumentService $workflowDocumentService WorkflowDocumentService $workflowDocumentService
){ ) {
parent::__construct($security, $workflowDocumentService); parent::__construct($security, $workflowDocumentService);
} }
@ -26,9 +35,6 @@ class EventStoredObjectVoter extends AbstractStoredObjectVoter
return $this->repository; return $this->repository;
} }
/**
* @inheritDoc
*/
protected function getClass(): string protected function getClass(): string
{ {
return Event::class; return Event::class;

View File

@ -1,5 +1,14 @@
<?php <?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\DocStoreBundle\Security\Authorization\StoredObjectVoters; namespace Chill\DocStoreBundle\Security\Authorization\StoredObjectVoters;
use Chill\DocStoreBundle\Entity\PersonDocument; use Chill\DocStoreBundle\Entity\PersonDocument;
@ -7,7 +16,6 @@ use Chill\DocStoreBundle\Repository\AssociatedEntityToStoredObjectInterface;
use Chill\DocStoreBundle\Repository\PersonDocumentRepository; use Chill\DocStoreBundle\Repository\PersonDocumentRepository;
use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter; use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter;
use Chill\DocStoreBundle\Security\Authorization\StoredObjectRoleEnum; use Chill\DocStoreBundle\Security\Authorization\StoredObjectRoleEnum;
use Chill\DocStoreBundle\Security\Authorization\StoredObjectVoters\AbstractStoredObjectVoter;
use Chill\DocStoreBundle\Service\WorkflowDocumentService; use Chill\DocStoreBundle\Service\WorkflowDocumentService;
use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Core\Security;
@ -17,7 +25,7 @@ class PersonDocumentStoredObjectVoter extends AbstractStoredObjectVoter
private readonly PersonDocumentRepository $repository, private readonly PersonDocumentRepository $repository,
Security $security, Security $security,
WorkflowDocumentService $workflowDocumentService WorkflowDocumentService $workflowDocumentService
){ ) {
parent::__construct($security, $workflowDocumentService); parent::__construct($security, $workflowDocumentService);
} }
@ -26,9 +34,6 @@ class PersonDocumentStoredObjectVoter extends AbstractStoredObjectVoter
return $this->repository; return $this->repository;
} }
/**
* @inheritDoc
*/
protected function getClass(): string protected function getClass(): string
{ {
return PersonDocument::class; return PersonDocument::class;

View File

@ -1,5 +1,14 @@
<?php <?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace src\Bundle\ChillDocStoreBundle\Security\Authorization\StoredObjectVoters; namespace src\Bundle\ChillDocStoreBundle\Security\Authorization\StoredObjectVoters;
use Chill\DocStoreBundle\Entity\PersonDocument; use Chill\DocStoreBundle\Entity\PersonDocument;
@ -17,7 +26,7 @@ class PersonStoredObjectVoter extends AbstractStoredObjectVoter
private readonly PersonDocumentRepository $repository, private readonly PersonDocumentRepository $repository,
Security $security, Security $security,
WorkflowDocumentService $workflowDocumentService WorkflowDocumentService $workflowDocumentService
){ ) {
parent::__construct($security, $workflowDocumentService); parent::__construct($security, $workflowDocumentService);
} }
@ -26,9 +35,6 @@ class PersonStoredObjectVoter extends AbstractStoredObjectVoter
return $this->repository; return $this->repository;
} }
/**
* @inheritDoc
*/
protected function getClass(): string protected function getClass(): string
{ {
return PersonDocument::class; return PersonDocument::class;

View File

@ -1,18 +1,23 @@
<?php <?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\DocStoreBundle\Service; namespace Chill\DocStoreBundle\Service;
use Chill\MainBundle\Entity\Workflow\EntityWorkflow; use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
use Chill\MainBundle\Repository\Workflow\EntityWorkflowRepository;
use Chill\MainBundle\Workflow\EntityWorkflowManager; use Chill\MainBundle\Workflow\EntityWorkflowManager;
use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Core\Security;
class WorkflowDocumentService class WorkflowDocumentService
{ {
public function __construct(private readonly Security $security, private readonly EntityWorkflowManager $entityWorkflowManager) {}
public function __construct(private readonly Security $security, private readonly EntityWorkflowManager $entityWorkflowManager)
{
}
public function notBlockedByWorkflow(object $entity): bool public function notBlockedByWorkflow(object $entity): bool
{ {
@ -22,7 +27,6 @@ class WorkflowDocumentService
$workflow = $this->entityWorkflowManager->findByRelatedEntity($entity); $workflow = $this->entityWorkflowManager->findByRelatedEntity($entity);
$currentUser = $this->security->getUser(); $currentUser = $this->security->getUser();
if (null != $workflow) { if (null != $workflow) {
if ($workflow->isFinal()) { if ($workflow->isFinal()) {
return false; return false;
@ -35,5 +39,4 @@ class WorkflowDocumentService
return true; return true;
} }
} }

View File

@ -18,19 +18,15 @@ use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
use Chill\MainBundle\Repository\Workflow\EntityWorkflowRepository; use Chill\MainBundle\Repository\Workflow\EntityWorkflowRepository;
use Chill\MainBundle\Workflow\EntityWorkflowHandlerInterface; use Chill\MainBundle\Workflow\EntityWorkflowHandlerInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation; use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Symfony\Contracts\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
readonly class AccompanyingCourseDocumentWorkflowHandler implements EntityWorkflowHandlerInterface readonly class AccompanyingCourseDocumentWorkflowHandler implements EntityWorkflowHandlerInterface
{ {
public function __construct( public function __construct(
private TranslatorInterface $translator, private TranslatorInterface $translator,
private EntityWorkflowRepository $workflowRepository, private EntityWorkflowRepository $workflowRepository,
private AccompanyingCourseDocumentRepository $repository private AccompanyingCourseDocumentRepository $repository
) { ) {}
}
public function getDeletionRoles(): array public function getDeletionRoles(): array
{ {
@ -127,7 +123,7 @@ readonly class AccompanyingCourseDocumentWorkflowHandler implements EntityWorkfl
public function findByRelatedEntity(object $object): ?EntityWorkflow public function findByRelatedEntity(object $object): ?EntityWorkflow
{ {
if(!$object instanceof AccompanyingCourseDocument) { if (!$object instanceof AccompanyingCourseDocument) {
return null; return null;
} }

View File

@ -13,7 +13,6 @@ namespace Chill\EventBundle\Form\ChoiceLoader;
use Chill\EventBundle\Entity\Event; use Chill\EventBundle\Entity\Event;
use Chill\EventBundle\Repository\EventRepository; use Chill\EventBundle\Repository\EventRepository;
use Doctrine\ORM\EntityRepository;
use Symfony\Component\Form\ChoiceList\ChoiceListInterface; use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface; use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;

View File

@ -16,8 +16,6 @@ use Chill\DocStoreBundle\Repository\AssociatedEntityToStoredObjectInterface;
use Chill\EventBundle\Entity\Event; use Chill\EventBundle\Entity\Event;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\NonUniqueResultException;
use Doctrine\ORM\NoResultException;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ObjectRepository; use Doctrine\Persistence\ObjectRepository;

View File

@ -1,5 +1,14 @@
<?php <?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\EventBundle\Security\Authorization; namespace Chill\EventBundle\Security\Authorization;
use Chill\DocStoreBundle\Repository\AssociatedEntityToStoredObjectInterface; use Chill\DocStoreBundle\Repository\AssociatedEntityToStoredObjectInterface;
@ -8,7 +17,6 @@ use Chill\DocStoreBundle\Security\Authorization\StoredObjectVoters\AbstractStore
use Chill\DocStoreBundle\Service\WorkflowDocumentService; use Chill\DocStoreBundle\Service\WorkflowDocumentService;
use Chill\EventBundle\Entity\Event; use Chill\EventBundle\Entity\Event;
use Chill\EventBundle\Repository\EventRepository; use Chill\EventBundle\Repository\EventRepository;
use Chill\EventBundle\Security\Authorization\EventVoter;
use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Core\Security;
class EventStoredObjectVoter extends AbstractStoredObjectVoter class EventStoredObjectVoter extends AbstractStoredObjectVoter
@ -17,7 +25,7 @@ class EventStoredObjectVoter extends AbstractStoredObjectVoter
private readonly EventRepository $repository, private readonly EventRepository $repository,
Security $security, Security $security,
WorkflowDocumentService $workflowDocumentService WorkflowDocumentService $workflowDocumentService
){ ) {
parent::__construct($security, $workflowDocumentService); parent::__construct($security, $workflowDocumentService);
} }
@ -26,9 +34,6 @@ class EventStoredObjectVoter extends AbstractStoredObjectVoter
return $this->repository; return $this->repository;
} }
/**
* @inheritDoc
*/
protected function getClass(): string protected function getClass(): string
{ {
return Event::class; return Event::class;

View File

@ -112,7 +112,6 @@ class EntityWorkflowRepository implements ObjectRepository
->setParameter('entity_id', $relatedEntityId); ->setParameter('entity_id', $relatedEntityId);
return $query->getQuery()->getResult(); return $query->getQuery()->getResult();
} }
/** /**

View File

@ -43,7 +43,7 @@ class EntityWorkflowManager
foreach ($this->handlers as $handler) { foreach ($this->handlers as $handler) {
return $handler->findByRelatedEntity($object); return $handler->findByRelatedEntity($object);
} }
return null; return null;
} }
} }

View File

@ -11,7 +11,6 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Security\Authorization; namespace Chill\PersonBundle\Security\Authorization;
use Chill\DocStoreBundle\Security\Authorization\StoredObjectVoterInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluationDocument;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface; use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;

View File

@ -140,6 +140,7 @@ class AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler implements EntityW
if (!$object instanceof AccompanyingPeriodWorkEvaluationDocument) { if (!$object instanceof AccompanyingPeriodWorkEvaluationDocument) {
return null; return null;
} }
return $this->workflowRepository->findByRelatedEntity(AccompanyingPeriodWorkEvaluationDocument::class, $object->getId()); return $this->workflowRepository->findByRelatedEntity(AccompanyingPeriodWorkEvaluationDocument::class, $object->getId());
} }
} }

View File

@ -133,6 +133,7 @@ class AccompanyingPeriodWorkWorkflowHandler implements EntityWorkflowHandlerInte
if (!$object instanceof AccompanyingPeriodWork) { if (!$object instanceof AccompanyingPeriodWork) {
return null; return null;
} }
return $this->workflowRepository->findByRelatedEntity(AccompanyingPeriodWork::class, $object->getId()); return $this->workflowRepository->findByRelatedEntity(AccompanyingPeriodWork::class, $object->getId());
} }
} }

View File

@ -12,7 +12,6 @@ declare(strict_types=1);
namespace Chill\WopiBundle\Service\Wopi; namespace Chill\WopiBundle\Service\Wopi;
use ChampsLibres\WopiLib\Contract\Entity\Document; use ChampsLibres\WopiLib\Contract\Entity\Document;
use Chill\DocStoreBundle\Repository\StoredObjectRepository; use Chill\DocStoreBundle\Repository\StoredObjectRepository;
use Chill\DocStoreBundle\Security\Authorization\StoredObjectRoleEnum; use Chill\DocStoreBundle\Security\Authorization\StoredObjectRoleEnum;
use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\User;
@ -70,7 +69,6 @@ class AuthorizationManager implements \ChampsLibres\WopiBundle\Contracts\Authori
{ {
$storedObject = $this->getRelatedStoredObject($document); $storedObject = $this->getRelatedStoredObject($document);
if ($this->security->isGranted(StoredObjectRoleEnum::SEE->value, $storedObject)) { if ($this->security->isGranted(StoredObjectRoleEnum::SEE->value, $storedObject)) {
return $this->isTokenValid($accessToken, $document, $request); return $this->isTokenValid($accessToken, $document, $request);
} }
@ -103,5 +101,4 @@ class AuthorizationManager implements \ChampsLibres\WopiBundle\Contracts\Authori
return false; return false;
} }
} }