Remove usage of deprecated Role class

This commit is contained in:
2023-08-31 17:08:18 +02:00
parent 76142c1264
commit 7c58880139
33 changed files with 55 additions and 80 deletions

View File

@@ -189,7 +189,7 @@ class EventController extends AbstractController
$reachablesCircles = $this->authorizationHelper->getReachableCircles(
$this->getUser(),
new Role(EventVoter::SEE),
EventVoter::SEE,
$person->getCenter()
);
@@ -274,7 +274,7 @@ class EventController extends AbstractController
*/
public function newPickCenterAction()
{
$role = new Role('CHILL_EVENT_CREATE');
$role = 'CHILL_EVENT_CREATE';
/**
* @var Center $centers
@@ -404,7 +404,7 @@ class EventController extends AbstractController
);
$builder->add('event_id', PickEventType::class, [
'role' => new Role('CHILL_EVENT_CREATE'),
'role' => 'CHILL_EVENT_CREATE',
'centers' => $person->getCenter(),
]);
@@ -451,7 +451,7 @@ class EventController extends AbstractController
);
$builder->add('person_id', PickPersonType::class, [
'role' => new Role('CHILL_EVENT_CREATE'),
'role' => 'CHILL_EVENT_CREATE',
'centers' => $event->getCenter(),
]);
@@ -630,7 +630,7 @@ class EventController extends AbstractController
$form = $this->createForm(EventType::class, $entity, [
'method' => 'POST',
'center' => $entity->getCenter(),
'role' => new Role('CHILL_EVENT_CREATE'),
'role' => 'CHILL_EVENT_CREATE',
]);
$form->add('submit', SubmitType::class, ['label' => 'Create']);
@@ -665,7 +665,7 @@ class EventController extends AbstractController
'action' => $this->generateUrl('chill_event__event_update', ['event_id' => $entity->getId()]),
'method' => 'PUT',
'center' => $entity->getCenter(),
'role' => new Role('CHILL_EVENT_CREATE'),
'role' => 'CHILL_EVENT_CREATE',
]);
$form->remove('center');

View File

@@ -59,7 +59,7 @@ class EventType extends AbstractType
$resolver
->setRequired(['center', 'role'])
->setAllowedTypes('center', Center::class)
->setAllowedTypes('role', Role::class);
->setAllowedTypes('role', 'string');
}
/**

View File

@@ -74,7 +74,7 @@ final class PickEventType extends AbstractType
->setDefault('centers', null);
$resolver
->setDefined('role')
->addAllowedTypes('role', [Role::class, 'null'])
->addAllowedTypes('role', ['string', 'null'])
->setDefault('role', null);
// add the default options

View File

@@ -119,7 +119,7 @@ class EventVoter extends AbstractChillVoter implements ProvideRoleHierarchyInter
// subject is null. We check that at least one center is reachable
$centers = $this->authorizationHelper
->getReachableCenters($token->getUser(), new Role($attribute));
->getReachableCenters($token->getUser(), $attribute);
return count($centers) > 0;

View File

@@ -116,7 +116,7 @@ class ParticipationVoter extends AbstractChillVoter implements ProvideRoleHierar
// subject is null. We check that at least one center is reachable
$centers = $this->authorizationHelper
->getReachableCenters($token->getUser(), new Role($attribute));
->getReachableCenters($token->getUser(), $attribute);
return count($centers) > 0;