comparison core/lib/Drupal/Core/PageCache/RequestPolicyInterface.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 <?php
2
3 namespace Drupal\Core\PageCache;
4
5 use Symfony\Component\HttpFoundation\Request;
6
7 /**
8 * Defines the interface for request policy implementations.
9 *
10 * The request policy is evaluated in order to determine whether delivery of a
11 * cached page should be attempted. The caller should do so if static::ALLOW is
12 * returned from the check() method.
13 */
14 interface RequestPolicyInterface {
15
16 /**
17 * Allow delivery of cached pages.
18 */
19 const ALLOW = 'allow';
20
21 /**
22 * Deny delivery of cached pages.
23 */
24 const DENY = 'deny';
25
26 /**
27 * Determines whether delivery of a cached page should be attempted.
28 *
29 * Note that the request-policy check runs very early. In particular it is
30 * not possible to determine the logged in user. Also the current route match
31 * is not yet present when the check runs. Therefore, request-policy checks
32 * need to be designed in a way such that they do not depend on any other
33 * service and only take in account the information present on the incoming
34 * request.
35 *
36 * When matching against the request path, special attention is needed to
37 * support path prefixes which are often used on multilingual sites.
38 *
39 * @param \Symfony\Component\HttpFoundation\Request $request
40 * The incoming request object.
41 *
42 * @return string|null
43 * One of static::ALLOW, static::DENY or NULL. Calling code may attempt to
44 * deliver a cached page if static::ALLOW is returned. Returns NULL if the
45 * policy is not specified for the given request.
46 */
47 public function check(Request $request);
48
49 }