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