Class page_cache_kill_switch - Source Code

Primary tabs

API docs: https://api.drupal.org/api/drupal/core!lib!Drupal!Core!PageCache!ResponsePolicy!KillSwitch.php/11.3.x

GitLab: https://git.drupalcode.org/project/drupal/-/blob/11.3.x/core/lib/Drupal/Core/PageCache/ResponsePolicy/KillSwitch.php

Location: /core/lib/Drupal/Core/PageCache/ResponsePolicy/KillSwitch.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;
  }

}