person document: fix use of deprecated role class

This commit is contained in:
Julien Fastré 2021-12-17 00:33:02 +01:00
parent 773aee5534
commit 36890a2256
4 changed files with 10 additions and 7 deletions

View File

@ -24,7 +24,6 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Role\Role;
use Symfony\Component\Translation\TranslatorInterface;
/**
@ -100,7 +99,7 @@ class DocumentPersonController extends AbstractController
$document,
[
'center' => $document->getCenter(),
'role' => new Role('CHILL_PERSON_DOCUMENT_UPDATE'),
'role' => 'CHILL_PERSON_DOCUMENT_UPDATE',
]
);
$form->handleRequest($request);
@ -160,7 +159,7 @@ class DocumentPersonController extends AbstractController
$reachableScopes = $this->authorizationHelper
->getReachableScopes(
$this->getUser(),
new Role(PersonDocumentVoter::SEE),
PersonDocumentVoter::SEE,
$person->getCenter()
);
@ -204,7 +203,7 @@ class DocumentPersonController extends AbstractController
$form = $this->createForm(PersonDocumentType::class, $document, [
'center' => $document->getCenter(),
'role' => new Role('CHILL_PERSON_DOCUMENT_CREATE'),
'role' => 'CHILL_PERSON_DOCUMENT_CREATE',
]);
$form->handleRequest($request);

View File

@ -93,7 +93,7 @@ class PersonDocumentType extends AbstractType
]);
$resolver->setRequired(['role', 'center'])
->setAllowedTypes('role', [\Symfony\Component\Security\Core\Role\Role::class])
->setAllowedTypes('role', ['string'])
->setAllowedTypes('center', [\Chill\MainBundle\Entity\Center::class]);
}
}

View File

@ -32,7 +32,11 @@
{{ form_row(form.title) }}
{{ form_row(form.date) }}
{{ form_row(form.category) }}
{% if form.scope is defined %}
{{ form_row(form.scope) }}
{% endif %}
{{ form_row(form.description) }}
{{ form_row(form.object, { 'label': 'Document', 'existing': document.object }) }}

View File

@ -80,7 +80,7 @@ class ScopePickerType extends AbstractType
{
$items = $this->authorizationHelper->getReachableScopes(
$this->security->getUser(),
$options['role']->getRole(),
$options['role'] instanceof Role ? $options['role']->getRole() : $options['role'],
$options['center']
);