Added permission system, to control who can edit Twig labels.

This commit is contained in:
Jan Böhmer 2020-05-07 22:29:45 +02:00
parent f1a6bc31a1
commit 1a35adab17
6 changed files with 41 additions and 8 deletions

View file

@ -165,11 +165,22 @@ abstract class BaseAdminController extends AbstractController
$table = null;
}
$form = $this->createForm($this->form_class, $entity, [
$form_options = [
'attachment_class' => $this->attachment_class,
'parameter_class' => $this->parameter_class,
'disabled' => null !== $timeTravel_timestamp ? true : null,
]);
];
//Disable editing of options, if user is not allowed to use twig...
if (
$entity instanceof LabelProfile
&& $entity->getOptions()->getLinesMode() === 'twig'
&& !$this->isGranted('@labels.use_twig')
) {
$form_options['disable_options'] = true;
}
$form = $this->createForm($this->form_class, $entity, $form_options);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {