Add annotations to APIRole and Role controllers #222
This commit is contained in:
parent
4ccdb8c5aa
commit
b6f7d70e13
2 changed files with 44 additions and 26 deletions
|
|
@ -2,37 +2,37 @@
|
||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use App\Ramcar\BaseController;
|
|
||||||
|
|
||||||
use Catalyst\APIBundle\Entity\Role as APIRole;
|
use Catalyst\APIBundle\Entity\Role as APIRole;
|
||||||
use Catalyst\APIBundle\Access\Generator as APIACLGenerator;
|
use Catalyst\APIBundle\Access\Generator as APIACLGenerator;
|
||||||
|
|
||||||
use Doctrine\ORM\Query;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
|
use Doctrine\ORM\Query;
|
||||||
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
|
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
|
||||||
|
|
||||||
use App\Menu\Generator as MenuGenerator;
|
use Catalyst\MenuBundle\Annotation\Menu;
|
||||||
|
|
||||||
class APIRoleController extends BaseController
|
|
||||||
|
class APIRoleController extends Controller
|
||||||
{
|
{
|
||||||
protected $api_acl_gen;
|
protected $api_acl_gen;
|
||||||
|
|
||||||
public function __construct(MenuGenerator $menu_gen, APIACLGenerator $api_acl_gen)
|
public function __construct(APIACLGenerator $api_acl_gen)
|
||||||
{
|
{
|
||||||
$this->api_acl_gen = $api_acl_gen;
|
$this->api_acl_gen = $api_acl_gen;
|
||||||
parent::__construct($menu_gen);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Menu(selected="api_role_list")
|
||||||
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('apirole.list', null, 'No access.');
|
$this->denyAccessUnlessGranted('apirole.list', null, 'No access.');
|
||||||
|
|
||||||
$params = $this->initParameters('api_role_list');
|
|
||||||
|
|
||||||
// response
|
// response
|
||||||
return $this->render('api-role/list.html.twig', $params);
|
return $this->render('api-role/list.html.twig');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rows(Request $req)
|
public function rows(Request $req)
|
||||||
|
|
@ -128,11 +128,14 @@ class APIRoleController extends BaseController
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Menu(selected="api_role_list")
|
||||||
|
*/
|
||||||
public function addForm()
|
public function addForm()
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('apirole.add', null, 'No access.');
|
$this->denyAccessUnlessGranted('apirole.add', null, 'No access.');
|
||||||
|
|
||||||
$params = $this->initParameters('apirole_list');
|
$params = [];
|
||||||
$this->padAPIACLHierarchy($params);
|
$this->padAPIACLHierarchy($params);
|
||||||
$params['obj'] = new APIRole();
|
$params['obj'] = new APIRole();
|
||||||
$params['mode'] = 'create';
|
$params['mode'] = 'create';
|
||||||
|
|
@ -194,11 +197,14 @@ class APIRoleController extends BaseController
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Menu(selected="api_role_list")
|
||||||
|
*/
|
||||||
public function updateForm($id)
|
public function updateForm($id)
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('apirole.update', null, 'No access.');
|
$this->denyAccessUnlessGranted('apirole.update', null, 'No access.');
|
||||||
|
|
||||||
$params = $this->initParameters('api_role_list');
|
$params = [];
|
||||||
$this->padAPIACLHierarchy($params);
|
$this->padAPIACLHierarchy($params);
|
||||||
$params['mode'] = 'update';
|
$params['mode'] = 'update';
|
||||||
|
|
||||||
|
|
@ -291,11 +297,14 @@ class APIRoleController extends BaseController
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Menu(selected="api_role_list")
|
||||||
|
*/
|
||||||
public function destroy($id)
|
public function destroy($id)
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('apirole.delete', null, 'No access.');
|
$this->denyAccessUnlessGranted('apirole.delete', null, 'No access.');
|
||||||
|
|
||||||
$params = $this->initParameters('apirole_list');
|
$params = [];
|
||||||
|
|
||||||
// get row data
|
// get row data
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
|
||||||
|
|
@ -2,36 +2,36 @@
|
||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use App\Ramcar\BaseController;
|
|
||||||
use App\Entity\Role;
|
use App\Entity\Role;
|
||||||
|
|
||||||
use Doctrine\ORM\Query;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Doctrine\ORM\Query;
|
||||||
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
|
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
|
||||||
|
|
||||||
use App\Menu\Generator as MenuGenerator;
|
|
||||||
use Catalyst\AuthBundle\Service\ACLGenerator;
|
use Catalyst\AuthBundle\Service\ACLGenerator;
|
||||||
|
use Catalyst\MenuBundle\Annotation\Menu;
|
||||||
|
|
||||||
class RoleController extends BaseController
|
class RoleController extends Controller
|
||||||
{
|
{
|
||||||
protected $acl_gen;
|
protected $acl_gen;
|
||||||
|
|
||||||
public function __construct(MenuGenerator $menu_gen, ACLGenerator $acl_gen)
|
public function __construct(ACLGenerator $acl_gen)
|
||||||
{
|
{
|
||||||
$this->acl_gen = $acl_gen;
|
$this->acl_gen = $acl_gen;
|
||||||
parent::__construct($menu_gen);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Menu(selected="role_list")
|
||||||
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('role.list', null, 'No access.');
|
$this->denyAccessUnlessGranted('role.list', null, 'No access.');
|
||||||
|
|
||||||
$params = $this->initParameters('role_list');
|
|
||||||
|
|
||||||
// response
|
// response
|
||||||
return $this->render('role/list.html.twig', $params);
|
return $this->render('role/list.html.twig');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rows(Request $req)
|
public function rows(Request $req)
|
||||||
|
|
@ -134,11 +134,14 @@ class RoleController extends BaseController
|
||||||
$params['acl_hierarchy'] = $acl_data['hierarchy'];
|
$params['acl_hierarchy'] = $acl_data['hierarchy'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Menu(selected="role_list")
|
||||||
|
*/
|
||||||
public function addForm()
|
public function addForm()
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('role.add', null, 'No access.');
|
$this->denyAccessUnlessGranted('role.add', null, 'No access.');
|
||||||
|
|
||||||
$params = $this->initParameters('role_list');
|
$params = [];
|
||||||
$this->padACLHierarchy($params);
|
$this->padACLHierarchy($params);
|
||||||
$params['obj'] = new Role();
|
$params['obj'] = new Role();
|
||||||
$params['mode'] = 'create';
|
$params['mode'] = 'create';
|
||||||
|
|
@ -200,11 +203,14 @@ class RoleController extends BaseController
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Menu(selected="role_list")
|
||||||
|
*/
|
||||||
public function updateForm($id)
|
public function updateForm($id)
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('role.update', null, 'No access.');
|
$this->denyAccessUnlessGranted('role.update', null, 'No access.');
|
||||||
|
|
||||||
$params = $this->initParameters('role_list');
|
$params = [];
|
||||||
$this->padACLHierarchy($params);
|
$this->padACLHierarchy($params);
|
||||||
$params['mode'] = 'update';
|
$params['mode'] = 'update';
|
||||||
|
|
||||||
|
|
@ -297,11 +303,14 @@ class RoleController extends BaseController
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Menu(selected="role_list")
|
||||||
|
*/
|
||||||
public function destroy($id)
|
public function destroy($id)
|
||||||
{
|
{
|
||||||
$this->denyAccessUnlessGranted('role.delete', null, 'No access.');
|
$this->denyAccessUnlessGranted('role.delete', null, 'No access.');
|
||||||
|
|
||||||
$params = $this->initParameters('role_list');
|
$params = [];
|
||||||
|
|
||||||
// get row data
|
// get row data
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue