function ChainRequestPolicy::check

Same name in other branches
  1. 9 core/lib/Drupal/Core/PageCache/ChainRequestPolicy.php \Drupal\Core\PageCache\ChainRequestPolicy::check()
  2. 10 core/lib/Drupal/Core/PageCache/ChainRequestPolicy.php \Drupal\Core\PageCache\ChainRequestPolicy::check()
  3. 11.x core/lib/Drupal/Core/PageCache/ChainRequestPolicy.php \Drupal\Core\PageCache\ChainRequestPolicy::check()

Overrides RequestPolicyInterface::check

File

core/lib/Drupal/Core/PageCache/ChainRequestPolicy.php, line 33

Class

ChainRequestPolicy
Implements a compound request policy.

Namespace

Drupal\Core\PageCache

Code

public function check(Request $request) {
    $final_result = NULL;
    foreach ($this->rules as $rule) {
        $result = $rule->check($request);
        if ($result === static::DENY) {
            return $result;
        }
        elseif ($result === static::ALLOW) {
            $final_result = $result;
        }
        elseif (isset($result)) {
            throw new \UnexpectedValueException('Return value of RequestPolicyInterface::check() must be one of RequestPolicyInterface::ALLOW, RequestPolicyInterface::DENY or NULL');
        }
    }
    return $final_result;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.