You are here

interface RequestPolicyInterface in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/PageCache/RequestPolicyInterface.php \Drupal\Core\PageCache\RequestPolicyInterface

Defines the interface for request policy implementations.

The request policy is evaluated in order to determine whether delivery of a cached page should be attempted. The caller should do so if static::ALLOW is returned from the check() method.

Hierarchy

Expanded class hierarchy of RequestPolicyInterface

All classes that implement RequestPolicyInterface

14 files declare their use of RequestPolicyInterface
AllowToolbarPath.php in core/modules/toolbar/src/PageCache/AllowToolbarPath.php
AllowToolbarPathTest.php in core/modules/toolbar/tests/src/Unit/PageCache/AllowToolbarPathTest.php
ChainRequestPolicyTest.php in core/tests/Drupal/Tests/Core/PageCache/ChainRequestPolicyTest.php
CommandLineOrUnsafeMethod.php in core/lib/Drupal/Core/PageCache/RequestPolicy/CommandLineOrUnsafeMethod.php
CommandLineOrUnsafeMethodTest.php in core/tests/Drupal/Tests/Core/PageCache/CommandLineOrUnsafeMethodTest.php

... See full list

File

core/lib/Drupal/Core/PageCache/RequestPolicyInterface.php, line 14

Namespace

Drupal\Core\PageCache
View source
interface RequestPolicyInterface {

  /**
   * Allow delivery of cached pages.
   */
  const ALLOW = 'allow';

  /**
   * Deny delivery of cached pages.
   */
  const DENY = 'deny';

  /**
   * 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.
   *
   * @param \Symfony\Component\HttpFoundation\Request $request
   *   The incoming request object.
   *
   * @return 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.
   */
  public function check(Request $request);

}

Members

Namesort descending Modifiers Type Description Overrides
RequestPolicyInterface::ALLOW constant Allow delivery of cached pages.
RequestPolicyInterface::check public function Determines whether delivery of a cached page should be attempted. 6
RequestPolicyInterface::DENY constant Deny delivery of cached pages.