Skip to content
Snippets Groups Projects

Issue #3493008 by freelock: Action plugin for Page Cache Kill Switch

Merged John Locke requested to merge issue/eca-3493008:3493008-action-plugin-for into 3.0.x
Files
2
 
<?php
 
 
namespace Drupal\eca_cache\Plugin\Action;
 
 
use Drupal\Core\PageCache\ResponsePolicy\KillSwitch;
 
use Symfony\Component\DependencyInjection\ContainerInterface;
 
use Drupal\eca\Plugin\Action\ConfigurableActionBase;
 
 
/**
 
* Provides a Page Cache Kill Switch action.
 
*
 
* @Action(
 
* id = "eca_page_cache_kill_switch",
 
* label = @Translation("Page Cache Kill Switch"),
 
* description = @Translation("Kill the page cache for this page")
 
* )
 
*/
 
class PageCacheKillSwitch extends ConfigurableActionBase {
 
 
/**
 
* The kill switch response policy.
 
*
 
* @var \Drupal\Core\PageCache\ResponsePolicy\KillSwitch
 
*/
 
protected KillSwitch $killSwitch;
 
 
/**
 
* {@inheritdoc}
 
*/
 
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition): static {
 
$self = parent::create(
 
$container,
 
$configuration,
 
$plugin_id,
 
$plugin_definition
 
);
 
$self->killSwitch = $container->get('page_cache_kill_switch');
 
return $self;
 
}
 
 
/**
 
* {@inheritdoc}
 
*/
 
public function execute(): void {
 
$this->killSwitch->trigger();
 
}
 
 
}
Loading