Skip to content

Instantly share code, notes, and snippets.

@PSF1
Created December 3, 2019 18:03
Show Gist options
  • Save PSF1/60df9acc53f48f6a8098ad8b1b92fcf6 to your computer and use it in GitHub Desktop.
Save PSF1/60df9acc53f48f6a8098ad8b1b92fcf6 to your computer and use it in GitHub Desktop.
Drupal\Core\PageCache\ResponsePolicy\KillSwitch
class ...
/**
* Kill cache service.
*
* @var \Drupal\Core\PageCache\ResponsePolicy\KillSwitch
*/
protected $killSwitch;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
...
$container->get('page_cache_kill_switch'),
...
);
}
...
/**
* Constructs a new GetReservableAvailabilityToDayRestResource object.
*
* @param \Drupal\Core\PageCache\ResponsePolicy\KillSwitch $killSwitch
* The cache killer.
*/
public function __construct(
KillSwitch $killSwitch
) {
...
$this->killSwitch = $killSwitch;
...
}
...
public function loginSwitcher() {
...
// Don't allow cache this response.
$this->killSwitch->trigger();
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment