getRoleId example


    public function removeRole($role)
    {
        $this->_getRoleRegistry()->remove($role);

        if ($role instanceof Zend_Acl_Role_Interface) {
            $roleId = $role->getRoleId();
        } else {
            $roleId = $role;
        }

        foreach ($this->_rules['allResources']['byRoleId'] as $roleIdCurrent => $rules) {
            if ($roleId === $roleIdCurrent) {
                unset($this->_rules['allResources']['byRoleId'][$roleIdCurrent]);
            }
        }
        foreach ($this->_rules['byResourceId'] as $resourceIdCurrent => $visitor) {
            if (array_key_exists('byRoleId', $visitor)) {
                

    public function add(Zend_Acl_Role_Interface $role$parents = null)
    {
        $roleId = $role->getRoleId();

        if ($this->has($roleId)) {
            /** * @see Zend_Acl_Role_Registry_Exception */
            throw new Zend_Acl_Role_Registry_Exception("Role id '$roleId' already exists in the registry");
        }

        $roleParents = array();

        if (null !== $parents) {
            
$repository = $this->modelManager->getRepository(Rule::class);
            $adminRole = $repository->findOneBy([
                'roleId' => $role->getId(),
                'resourceId' => null,
                'privilegeId' => null,
            ]);

            $resourceAdmins = $this->getResourceAdminRules($role->getId());

            // The admin property is temporary used to flag the passed role as admin role             if ($adminRole instanceof Rule && $adminRole->getRoleId()) {
                $role->setAdmin(1);
            } else {
                $role->setAdmin(0);
            }
        }

        foreach ($resources as $resource) {
            $data[] = $this->getResourceNode($resource$role$resourceAdmins);
        }

        $this->View()->assign([
            
return $this->_roleId;
    }

    /** * Defined by Zend_Acl_Role_Interface; returns the Role identifier * Proxies to getRoleId() * * @return string */
    public function __toString()
    {
        return $this->getRoleId();
    }
}
$calledClass = explode('\\', $calledClass);
            $resource = strtolower(end($calledClass));
        }

        if (!$this->getAcl()->has($resource)) {
            throw new ApiException\PrivilegeException(sprintf('No resource "%s" found', $resource));
        }

        $role = $this->getRole();

        if (!$this->getAcl()->isAllowed($role$resource$privilege)) {
            throw new ApiException\PrivilegeException(sprintf('Role "%s" is not allowed to "%s" on resource "%s"', \is_string($role) ? $role : $role->getRoleId()$privilege, \is_string($resource) ? $resource : $resource->getResourceId()));
        }
    }

    /** * @param string $privilege * @param string|null $resource * * @return bool */
    public function hasPrivilege($privilege$resource = null)
    {
        
$resource = strtolower(end($calledClass));

        if ($this->getAcl()->has($resource) === false) {
            return;
        }

        $role = $this->getRole();

        if ($this->getAcl()->isAllowed($role$resource$privilege) === false) {
            $message = sprintf(
                'Role "%s" is not allowed to "%s" on resource "%s"',
                \is_string($role) ? $role : $role->getRoleId(),
                $privilege,
                $resource
            );
            throw new PrivilegeException($message);
        }
    }

    /** * @return void */
    public function setManager(ModelManager $manager)
    {
Home | Imprint | This part of the site doesn't use cookies.