Ejemplo n.º 1
0
 public function createRolePermission(Request $request, Session $session, $view)
 {
     if (!$request->getParameter(SUBMIT_PARAM)) {
         $this->setAttribute('role_id', $request->getParameter('role_id'));
         return new Template('create_role_permission');
     } else {
         $roleId = $request->getParameter('role_id');
         $permission = $request->getParameter('permission');
         $name = preg_replace('/^\\W+|\\W+|\\+s/', '', $permission);
         $service = new SecurityService();
         self::$_logger->debug('permission: ' . $permission);
         $permissionInfo = $service->getRolePermissionByHandle($roleId, $permission);
         if (!empty($permissionInfo)) {
             $result['response_code'] = -1;
             $result['message'] = 'This role permission already exists. Please enter a different one.';
         } else {
             $dataIn = $request->getParameters(true);
             $service->createRolePermission($dataIn);
             $result['response_code'] = 1;
         }
         return $this->showJsonResponse($result);
     }
 }