add IsGranted in all methods of the CrudController maker template

This commit is contained in:
Simon Vieille 2024-02-04 16:16:19 +01:00
parent 430bff9433
commit 614ae40901
1 changed files with 5 additions and 0 deletions

View File

@ -22,12 +22,14 @@ class <?php echo $class_name; ?> extends CrudController
protected ?CrudConfiguration $configuration = null;
#[Route(path: '/admin/<?php echo $route; ?>/{page}', name: 'admin_<?php echo $route; ?>_index', methods: ['GET'], requirements: ['page' => '\d+'])]
#[IsGranted('index', 'entity')]
public function index(RepositoryQuery $query, Request $request, Session $session, int $page = 1): Response
{
return $this->doIndex($page, $query, $request, $session);
}
#[Route(path: '/admin/<?php echo $route; ?>/new', name: 'admin_<?php echo $route; ?>_new', methods: ['GET', 'POST'])]
#[IsGranted('new', 'entity')]
public function new(Factory $factory, EntityManager $entityManager, Request $request): Response
{
return $this->doNew($factory->create(), $entityManager, $request);
@ -41,6 +43,7 @@ class <?php echo $class_name; ?> extends CrudController
}
#[Route(path: '/admin/<?php echo $route; ?>/filter', name: 'admin_<?php echo $route; ?>_filter', methods: ['GET'])]
#[IsGranted('filter', 'entity')]
public function filter(Session $session): Response
{
return $this->doFilter($session);
@ -61,12 +64,14 @@ class <?php echo $class_name; ?> extends CrudController
}
#[Route(path: '/admin/<?php echo $route; ?>/sort/{page}', name: 'admin_<?php echo $route; ?>_sort', methods: ['POST'], requirements: ['page' => '\d+'])]
#[IsGranted('sort', 'entity')]
public function sort(RepositoryQuery $query, EntityManager $entityManager, Request $request, Session $session, int $page = 1): Response
{
return $this->doSort($page, $query, $entityManager, $request, $session);
}
#[Route(path: '/admin/<?php echo $route; ?>/batch/{page}', name: 'admin_<?php echo $route; ?>_batch', methods: ['POST'], requirements: ['page' => '\d+'])]
#[IsGranted('batch', 'entity')]
public function batch(RepositoryQuery $query, EntityManager $entityManager, Request $request, Session $session, int $page = 1): Response
{
return $this->doBatch($page, $query, $entityManager, $request, $session);