/** * @inheritdoc */ public function isValid($data, $field = '', array $extra = []) { if (is_array($data) && array_key_exists($field, $data)) { return $this->isValid($data[$field], $field, $extra); } return $this->roleRepository->roleExistsByName($data, isset($extra['role_id']) ? $extra['role_id'] : 0) === false; }
/** * @param int $id * @param string $action * * @return \Symfony\Component\HttpFoundation\RedirectResponse * @throws \ACP3\Core\Controller\Exception\ResultNotExistsException */ public function execute($id, $action) { if ($this->roleRepository->roleExists($id) === true) { $this->sortOperation->execute($id, $action); $this->permissionsCache->getCacheDriver()->deleteAll(); return $this->redirect()->temporary('acp/permissions'); } throw new Core\Controller\Exception\ResultNotExistsException(); }
/** * Insert new acl user rules * * @param string $moduleName */ protected function insertAclRules($moduleName) { $roles = $this->roleRepository->getAllRoles(); $privileges = $this->privilegeRepository->getAllPrivilegeIds(); $moduleId = $this->schemaHelper->getModuleId($moduleName); foreach ($roles as $role) { foreach ($privileges as $privilege) { $insertValues = ['id' => '', 'role_id' => $role['id'], 'module_id' => $moduleId, 'privilege_id' => $privilege['id'], 'permission' => $this->getDefaultAclRulePermission($role, $privilege)]; $this->ruleRepository->insert($insertValues); } } }
/** * Ermittelt die Berechtigung einer Privilegie von einer übergeordneten Rolle * * @param string $privilegeKey * @param integer $roleId * * @return integer */ protected function getPermissionValue($privilegeKey, $roleId) { $value = $this->roleRepository->getPermissionByKeyAndRoleId($privilegeKey, $roleId); return isset($value['permission']) ? $value['permission'] : Core\ACL\PermissionEnum::DENY_ACCESS; }