ChainRequestPolicy::check
public function ChainRequestPolicy::check
public ChainRequestPolicy::check(Request $request)
Determines whether delivery of a cached page should be attempted.
Note that the request-policy check runs very early. In particular it is not possible to determine the logged in user. Also the current route match is not yet present when the check runs. Therefore, request-policy checks need to be designed in a way such that they do not depend on any other service and only take in account the information present on the incoming request.
When matching against the request path, special attention is needed to support path prefixes which are often used on multilingual sites.
Parameters
\Symfony\Component\HttpFoundation\Request $request: The incoming request object.
Return value
string|NULL One of static::ALLOW, static::DENY or NULL. Calling code may attempt to deliver a cached page if static::ALLOW is returned. Returns NULL if the policy is not specified for the given request.
Overrides RequestPolicyInterface::check
File
- core/lib/Drupal/Core/PageCache/ChainRequestPolicy.php, line 33
Class
- ChainRequestPolicy
- Implements a compound request policy.
Namespace
Drupal\Core\PageCacheCode
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; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!PageCache!ChainRequestPolicy.php/function/ChainRequestPolicy::check/8.1.x