getResourceId example


    public function addResource($resource$parent = null)
    {
        if (is_string($resource)) {
            $resource = new Zend_Acl_Resource($resource);
        }

        if (!$resource instanceof Zend_Acl_Resource_Interface) {
            throw new Zend_Acl_Exception('addResource() expects $resource to be of type Zend_Acl_Resource_Interface');
        }

        $resourceId = $resource->getResourceId();

        if ($this->has($resourceId)) {
            throw new Zend_Acl_Exception("Resource id '$resourceId' already exists in the ACL");
        }

        $resourceParent = null;

        if (null !== $parent) {
            try {
                if ($parent instanceof Zend_Acl_Resource_Interface) {
                    $resourceParentId = $parent->getResourceId();
                }

    private function getPrivilegeNode(array &$resourceNode, ?Privilege $privilege, ?Role $role): array
    {
        if (!$privilege) {
            return [];
        }

        $privilegeNode = [
            'id' => $privilege->getResourceId() . '_' . $privilege->getId(),
            'helperId' => $privilege->getId(),
            'resourceId' => $privilege->getResourceId(),
            'type' => 'privilege',
            'name' => $privilege->getName(),
            'checked' => $resourceNode['checked'] ? true : false,
            'expanded' => false,
            'leaf' => true,
            'requirements' => [],
        ];

        if (\count($privilege->getRequirements()) > 0) {
            
return $this->_resourceId;
    }

    /** * Defined by Zend_Acl_Resource_Interface; returns the Resource identifier * Proxies to getResourceId() * * @return string */
    public function __toString()
    {
        return $this->getResourceId();
    }
}
$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)
    {
        
Home | Imprint | This part of the site doesn't use cookies.