summaryrefslogtreecommitdiffstats
path: root/core/lib/Drupal/Core/PageCache/ResponsePolicyInterface.php
blob: 596f43fd9aaac7e83144a208b4f07ebe5b22a400 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php

/**
 * @file
 * Contains \Drupal\Core\PageCache\ResponsePolicyInterface.
 */

namespace Drupal\Core\PageCache;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

/**
 * Defines the interface for response policy implementations.
 *
 * The response policy is evaluated in order to determine whether a page should
 * be stored a in the cache. Calling code should do so unless static::DENY is
 * returned from the check() method.
 */
interface ResponsePolicyInterface {

  /**
   * Deny storage of a page in the cache.
   */
  const DENY = 'deny';

  /**
   * Determines whether it is save to store a page in the cache.
   *
   * @param \Symfony\Component\HttpFoundation\Response $response
   *   The response which is about to be sent to the client.
   * @param \Symfony\Component\HttpFoundation\Request $request
   *   The request object.
   *
   * @return string|NULL
   *   Either static::DENY or NULL. Calling code may attempt to store a page in
   *   the cache unless static::DENY is returned. Returns NULL if the policy
   *   policy is not specified for the given response.
   */
  public function check(Response $response, Request $request);

}