Neos\Flow\Security\Authorization\PrivilegeManager::isPrivilegeTargetGrantedForRoles PHP Method

isPrivilegeTargetGrantedForRoles() public method

Returns TRUE if access is granted on the given privilege target in the current security context
public isPrivilegeTargetGrantedForRoles ( array $roles, string $privilegeTargetIdentifier, array $privilegeParameters = [] ) : boolean
$roles array
$privilegeTargetIdentifier string The identifier of the privilege target to decide on
$privilegeParameters array Optional array of privilege parameters (simple key => value array)
return boolean TRUE if access is granted, FALSE otherwise
    public function isPrivilegeTargetGrantedForRoles(array $roles, $privilegeTargetIdentifier, array $privilegeParameters = [])
    {
        $privilegeFound = false;
        $accessGrants = 0;
        $accessDenies = 0;
        /** @var Role $role */
        foreach ($roles as $role) {
            $privilege = $role->getPrivilegeForTarget($privilegeTargetIdentifier, $privilegeParameters);
            if ($privilege === null) {
                continue;
            }
            $privilegeFound = true;
            if ($privilege->isGranted()) {
                $accessGrants++;
            } elseif ($privilege->isDenied()) {
                $accessDenies++;
            }
        }
        if ($accessDenies === 0 && $accessGrants > 0) {
            return true;
        }
        if ($accessDenies === 0 && $accessGrants === 0 && $privilegeFound === true && $this->allowAccessIfAllAbstain === true) {
            return true;
        }
        return false;
    }