mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-29 01:55:01 +00:00
fix cs and add EntityToIdTransformer
This commit is contained in:
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\CalendarBundle\Security\Voter;
|
||||
|
||||
use Chill\MainBundle\Security\Authorization\AbstractChillVoter;
|
||||
@@ -7,8 +16,8 @@ use Chill\MainBundle\Security\Authorization\VoterHelperFactoryInterface;
|
||||
use Chill\MainBundle\Security\Authorization\VoterHelperInterface;
|
||||
use Chill\MainBundle\Security\ProvideRoleHierarchyInterface;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||
use LogicException;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
@@ -16,12 +25,10 @@ class CalendarVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn
|
||||
{
|
||||
public const SEE = 'CHILL_CALENDAR_CALENDAR_SEE';
|
||||
|
||||
|
||||
private Security $security;
|
||||
|
||||
private VoterHelperInterface $voterHelper;
|
||||
|
||||
|
||||
public function __construct(
|
||||
Security $security,
|
||||
VoterHelperFactoryInterface $voterHelperFactory
|
||||
@@ -33,11 +40,6 @@ class CalendarVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn
|
||||
->build();
|
||||
}
|
||||
|
||||
public function getRolesWithHierarchy(): array
|
||||
{
|
||||
return ['Calendar' => $this->getRoles()];
|
||||
}
|
||||
|
||||
public function getRoles(): array
|
||||
{
|
||||
return [
|
||||
@@ -45,6 +47,11 @@ class CalendarVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn
|
||||
];
|
||||
}
|
||||
|
||||
public function getRolesWithHierarchy(): array
|
||||
{
|
||||
return ['Calendar' => $this->getRoles()];
|
||||
}
|
||||
|
||||
public function getRolesWithoutScope(): array
|
||||
{
|
||||
return [];
|
||||
@@ -60,20 +67,18 @@ class CalendarVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn
|
||||
if ($subject instanceof AccompanyingPeriod) {
|
||||
switch ($attribute) {
|
||||
case self::SEE:
|
||||
|
||||
if ($subject->getStep() === AccompanyingPeriod::STEP_DRAFT) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// we first check here that the user has read access to the period
|
||||
return $this->security->isGranted(AccompanyingPeriodVoter::SEE, $subject);
|
||||
|
||||
default:
|
||||
throw new \LogicException('subject not implemented');
|
||||
throw new LogicException('subject not implemented');
|
||||
}
|
||||
}
|
||||
|
||||
throw new \LogicException('attribute not implemented');
|
||||
throw new LogicException('attribute not implemented');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user