main/core/Manager/Resource/ResourceRestrictionsManager.php
public function getErrors(ResourceNode $resourceNode, array $userRoles): array
    {
        if (!$this->isGranted($resourceNode, $userRoles)) {
            // return restrictions details
            $errors = [
                'noRights' => !$this->hasRights($resourceNode, $userRoles),
                'deleted' => !$resourceNode->isActive(),
                'notPublished' => !$resourceNode->isPublished(),
            ];

            // optional restrictions
            // we return them only if they are enabled
            if (!empty($resourceNode->getAccessCode())) {
                $errors['locked'] = !$this->isUnlocked($resourceNode);
            }

            if (!empty($resourceNode->getAccessibleFrom()) || !empty($resourceNode->getAccessibleUntil())) {
                $errors['notStarted'] = !$this->isStarted($resourceNode);
                $errors['startDate'] = $resourceNode->getAccessibleFrom() ?
                    $resourceNode->getAccessibleFrom()->format('d/m/Y') :
                    null;
                $errors['ended'] = $this->isEnded($resourceNode);
            }

            if (!empty($resourceNode->getAllowedIps())) {
                $errors['invalidLocation'] = !$this->isIpAuthorized($resourceNode);
            }

            return $errors;
        }

        return [];
    }
public function getErrors(ResourceNode $resourceNode, array $userRoles): array
    {
        if (!$this->isGranted($resourceNode, $userRoles)) {
            // return restrictions details
            $errors = [
                'noRights' => !$this->hasRights($resourceNode, $userRoles),
                'deleted' => !$resourceNode->isActive(),
                'notPublished' => !$resourceNode->isPublished(),
            ];

            // optional restrictions
            // we return them only if they are enabled
            if (!empty($resourceNode->getAccessCode())) {
                $errors['locked'] = !$this->isUnlocked($resourceNode);
            }

            if (!empty($resourceNode->getAccessibleFrom()) || !empty($resourceNode->getAccessibleUntil())) {
                $errors['notStarted'] = !$this->isStarted($resourceNode);
                $errors['startDate'] = $resourceNode->getAccessibleFrom() ?
                    $resourceNode->getAccessibleFrom()->format('d/m/Y') :
                    null;
                $errors['ended'] = $this->isEnded($resourceNode);
            }

            if (!empty($resourceNode->getAllowedIps())) {
                $errors['invalidLocation'] = !$this->isIpAuthorized($resourceNode);
            }

            return $errors;
        }

        return [];
    }
public function getErrors ( ResourceNode $ resourceNode , array $ userRoles ) : array { if ( ! $ this -> isGranted ( $ resourceNode , $ userRoles ) ) { // return restrictions details $ errors = [ 'noRights' => ! $ this -> hasRights ( $ resourceNode , $ userRoles ) , 'deleted' => ! $ resourceNode -> isActive ( ) , 'notPublished' => ! $ resourceNode -> isPublished ( ) , ] ; // optional restrictions // we return them only if they are enabled if ( ! empty ( $ resourceNode -> getAccessCode ( ) ) ) { $ errors [ 'locked' ] = ! $ this -> isUnlocked ( $ resourceNode ) ; } if ( ! empty ( $ resourceNode -> getAccessibleFrom ( ) ) || ! empty ( $ resourceNode -> getAccessibleUntil ( ) ) ) { $ errors [ 'notStarted' ] = ! $ this -> isStarted ( $ resourceNode ) ; $ errors [ 'startDate' ] = $ resourceNode -> getAccessibleFrom ( ) ? $ resourceNode -> getAccessibleFrom ( ) -> format ( 'd/m/Y' ) : null ; $ errors [ 'ended' ] = $ this -> isEnded ( $ resourceNode ) ; } if ( ! empty ( $ resourceNode -> getAllowedIps ( ) ) ) { $ errors [ 'invalidLocation' ] = ! $ this -> isIpAuthorized ( $ resourceNode ) ; } return $ errors ; } return [ ] ; }
Gets the list of access error for a resource and a user roles.

@param ResourceNode $resourceNode
@param array        $userRoles

@return array
Gets the list of access error for a resource and a user roles .