KillSwitch.php

Same filename and directory in other branches
  1. 9 core/lib/Drupal/Core/PageCache/ResponsePolicy/KillSwitch.php
  2. 8.9.x core/lib/Drupal/Core/PageCache/ResponsePolicy/KillSwitch.php
  3. 10 core/lib/Drupal/Core/PageCache/ResponsePolicy/KillSwitch.php

Namespace

Drupal\Core\PageCache\ResponsePolicy

File

core/lib/Drupal/Core/PageCache/ResponsePolicy/KillSwitch.php

View source
<?php

namespace Drupal\Core\PageCache\ResponsePolicy;

use Drupal\Core\PageCache\ResponsePolicyInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

/**
 * A policy evaluating to static::DENY when the kill switch was triggered.
 */
class KillSwitch implements ResponsePolicyInterface {
    
    /**
     * A flag indicating whether the kill switch was triggered.
     *
     * @var bool
     */
    protected $kill = FALSE;
    
    /**
     * {@inheritdoc}
     */
    public function check(Response $response, Request $request) {
        if ($this->kill) {
            return static::DENY;
        }
    }
    
    /**
     * Deny any page caching on the current request.
     */
    public function trigger() {
        $this->kill = TRUE;
    }

}

Classes

Title Deprecated Summary
KillSwitch A policy evaluating to static::DENY when the kill switch was triggered.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.