li3_access\extensions\adapter\security\access\AuthRbac::check PHP Method

check() public method

The Rbac adapter will iterate through the rbac data Array.
public check ( mixed $requester, mixed $params, array $options = [] ) : Array
$requester mixed The user data array that holds all necessary information about the user requesting access. Or false (because Auth::check() can return false). This is an optional parameter, because we will fetch the users data through Auth seperately.
$params mixed The Lithium `Request` object, or an array with at least 'request', and 'params'
$options array An array of additional options for the _getRolesByAuth method.
return Array An empty array if access is allowed or an array with reasons for denial if denied.
    public function check($requester, $params, array $options = array())
    {
        if (empty($this->_roles)) {
            throw new ConfigException('No roles defined for adapter configuration.');
        }
        $roleDefaults = array('message' => '', 'redirect' => '', 'allow' => true, 'requesters' => '*', 'match' => '*::*');
        $message = $options['message'];
        $redirect = $options['redirect'];
        $accessible = false;
        foreach ($this->_roles as $role) {
            $role += $roleDefaults;
            if (is_callable($role['allow'])) {
                $role['allow'] = (array) $role['allow'];
            }
            // Check to see if this role applies to this request
            if (!static::parseMatch($role['match'], $params)) {
                continue;
            }
            $accessible = static::_isAccessible($role, $params, $options);
            if (!$accessible) {
                $message = !empty($role['message']) ? $role['message'] : $message;
                $redirect = !empty($role['redirect']) ? $role['redirect'] : $redirect;
            }
        }
        return !$accessible ? compact('message', 'redirect') : array();
    }