Version 1
[yaffs-website] / web / core / lib / Drupal / Core / PageCache / ResponsePolicy / KillSwitch.php
1 <?php
2
3 namespace Drupal\Core\PageCache\ResponsePolicy;
4
5 use Drupal\Core\PageCache\ResponsePolicyInterface;
6 use Symfony\Component\HttpFoundation\Request;
7 use Symfony\Component\HttpFoundation\Response;
8
9 /**
10  * A policy evaluating to static::DENY when the kill switch was triggered.
11  */
12 class KillSwitch implements ResponsePolicyInterface {
13
14   /**
15    * A flag indicating whether the kill switch was triggered.
16    *
17    * @var bool
18    */
19   protected $kill = FALSE;
20
21   /**
22    * {@inheritdoc}
23    */
24   public function check(Response $response, Request $request) {
25     if ($this->kill) {
26       return static::DENY;
27     }
28   }
29
30   /**
31    * Deny any page caching on the current request.
32    */
33   public function trigger() {
34     $this->kill = TRUE;
35   }
36
37 }