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

@@ -53,7 +53,6 @@ use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Role\Role;
use function in_array;
class ActivityType extends AbstractType
@@ -410,7 +409,7 @@ class ActivityType extends AbstractType
$resolver
->setRequired(['center', 'role', 'activityType', 'accompanyingPeriod'])
->setAllowedTypes('center', ['null', Center::class])
->setAllowedTypes('role', [Role::class, 'string'])
->setAllowedTypes('role', ['string'])
->setAllowedTypes('activityType', \Chill\ActivityBundle\Entity\ActivityType::class)
->setAllowedTypes('accompanyingPeriod', [\Chill\PersonBundle\Entity\AccompanyingPeriod::class, 'null']);
}

View File

@@ -354,14 +354,14 @@ final class ActivityControllerTest extends WebTestCase
->get('chill.main.security.authorization.helper')
->getReachableScopes(
$user,
new Role('CHILL_ACTIVITY_UPDATE'),
'CHILL_ACTIVITY_UPDATE',
$center
);
$reachableScopesDelete = self::$kernel->getContainer()
->get('chill.main.security.authorization.helper')
->getReachableScopes(
$user,
new Role('CHILL_ACTIVITY_DELETE'),
'CHILL_ACTIVITY_DELETE',
$center
);
$reachableScopesId = array_intersect(

View File

@@ -30,11 +30,6 @@ final class ActivityTypeTest extends KernelTestCase
*/
protected $center;
/**
* @var \Symfony\Component\DependencyInjection\ContainerInterface
*/
protected $container;
/**
* @var \Symfony\Component\Form\FormBuilderInterface
*/
@@ -85,7 +80,7 @@ final class ActivityTypeTest extends KernelTestCase
$form = $this->formBuilder
->add('activity', ActivityType::class, [
'center' => $this->center,
'role' => new Role('CHILL_ACTIVITY_CREATE'),
'role' => 'CHILL_ACTIVITY_CREATE',
])
->getForm();
@@ -101,7 +96,7 @@ final class ActivityTypeTest extends KernelTestCase
$form = $this->formBuilder
->add('activity', ActivityType::class, [
'center' => $this->center,
'role' => new Role('CHILL_ACTIVITY_CREATE'),
'role' => 'CHILL_ACTIVITY_CREATE',
])
->getForm();
@@ -157,7 +152,7 @@ final class ActivityTypeTest extends KernelTestCase
$form = $builder
->add('activity', ActivityType::class, [
'center' => $this->center,
'role' => new Role('CHILL_ACTIVITY_CREATE'),
'role' => 'CHILL_ACTIVITY_CREATE',
])
->getForm();

View File

@@ -141,8 +141,8 @@ class TimelineActivityProvider implements TimelineProviderInterface
$parameters = [];
$metadataActivity = $this->em->getClassMetadata(Activity::class);
$associationMapping = $metadataActivity->getAssociationMapping('person');
$role = new Role('CHILL_ACTIVITY_SEE');
$reachableScopes = $this->helper->getReachableScopes($this->user, $role->getRole(), $person->getCenter());
$role = 'CHILL_ACTIVITY_SEE';
$reachableScopes = $this->helper->getReachableScopes($this->user, $role, $person->getCenter());
$whereClause = ' {activity.person_id} = ? AND {activity.scope_id} IN ({scopes_ids}) ';
$scopes_ids = [];