class AcquiaPlatformCdnPurger in Acquia Purge 8
Acquia Platform CDN (beta).
Plugin annotation
@PurgePurger(
id = "acquia_platform_cdn",
label = @Translation("Acquia Platform CDN (beta)"),
configform = "",
cooldown_time = 0.0,
description = @Translation("Invalidate content from Acquia Platform CDN."),
multi_instance = FALSE,
types = {"url", "tag", "everything"},
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\purge\Plugin\Purge\Purger\PurgerBase implements PurgerInterface uses PurgeLoggerAwareTrait
- class \Drupal\acquia_purge\Plugin\Purge\Purger\AcquiaPlatformCdnPurger implements DebuggerAwareInterface, PurgerInterface uses DebuggerAwareTrait
- class \Drupal\purge\Plugin\Purge\Purger\PurgerBase implements PurgerInterface uses PurgeLoggerAwareTrait
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of AcquiaPlatformCdnPurger
File
- src/
Plugin/ Purge/ Purger/ AcquiaPlatformCdnPurger.php, line 25
Namespace
Drupal\acquia_purge\Plugin\Purge\PurgerView source
class AcquiaPlatformCdnPurger extends PurgerBase implements DebuggerAwareInterface, PurgerInterface {
use DebuggerAwareTrait;
/**
* The Acquia Platform CDN backend.
*
* @var null|\Drupal\acquia_purge\AcquiaPlatformCdn\BackendInterface
*/
protected $backend = NULL;
/**
* Information object interfacing with the Acquia platform.
*
* @var \Drupal\acquia_purge\AcquiaCloud\PlatformInfoInterface
*/
protected $platformInfo;
/**
* The Guzzle HTTP client.
*
* @var \GuzzleHttp\ClientInterface
*/
protected $httpClient;
/**
* Constructs a AcquiaCdnPurger object.
*
* @param \Drupal\acquia_purge\AcquiaCloud\PlatformInfoInterface $acquia_purge_platforminfo
* Information object interfacing with the Acquia platform.
* @param \GuzzleHttp\ClientInterface $http_client
* An HTTP client that can perform remote requests.
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
*/
public final function __construct(PlatformInfoInterface $acquia_purge_platforminfo, ClientInterface $http_client, array $configuration, $plugin_id, $plugin_definition) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->platformInfo = $acquia_purge_platforminfo;
$this->httpClient = $http_client;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($container
->get('acquia_purge.platforminfo'), $container
->get('http_client'), $configuration, $plugin_id, $plugin_definition);
}
/**
* {@inheritdoc}
*/
public function hasRuntimeMeasurement() {
return TRUE;
}
/**
* Lazy load the underlying backend based on PlatformInfo CDN configuration.
*
* @warning
* Don't call this from the constructor!
*/
protected function initializeBackend() {
if (!is_null($this->backend)) {
return;
}
$this
->debugger()
->callerAdd(__METHOD__);
// Attempt to load the backend or halt code execution.
$this->backend = BackendFactory::get($this->platformInfo, $this
->logger(), $this
->debugger(), $this->httpClient);
if (!$this->backend) {
throw new \RuntimeException("AcquiaPlatformCdnPurger has no backend!");
}
// Instantiate the backend and inject the logger.
$this
->debugger()
->callerAdd($this->backend);
}
/**
* {@inheritdoc}
*/
public function invalidate(array $invalidations) {
// Since we implemented ::routeTypeToMethod(), this Latin preciousness
// shouldn't ever occur and when it does, will be easily recognized.
throw new \Exception("Malum consilium quod mutari non potest!");
}
/**
* Invalidate a set of tag invalidations.
*
* @see \Drupal\purge\Plugin\Purge\Purger\PurgerInterface::invalidate()
* @see \Drupal\purge\Plugin\Purge\Purger\PurgerInterface::routeTypeToMethod()
*/
public function invalidateTags(array $invalidations) {
$this
->initializeBackend();
$this
->debugger()
->callerAdd(__METHOD__);
$this->backend
->invalidateTags($invalidations);
$this
->debugger()
->callerRemove(__METHOD__);
}
/**
* Invalidate a set of URL invalidations.
*
* @see \Drupal\purge\Plugin\Purge\Purger\PurgerInterface::invalidate()
* @see \Drupal\purge\Plugin\Purge\Purger\PurgerInterface::routeTypeToMethod()
*/
public function invalidateUrls(array $invalidations) {
$this
->initializeBackend();
$this
->debugger()
->callerAdd(__METHOD__);
$this->backend
->invalidateUrls($invalidations);
$this
->debugger()
->callerRemove(__METHOD__);
}
/**
* Invalidate the entire CDN.
*
* @see \Drupal\purge\Plugin\Purge\Purger\PurgerInterface::invalidate()
* @see \Drupal\purge\Plugin\Purge\Purger\PurgerInterface::routeTypeToMethod()
*/
public function invalidateEverything(array $invalidations) {
$this
->initializeBackend();
$this
->debugger()
->callerAdd(__METHOD__);
$this->backend
->invalidateEverything($invalidations);
$this
->debugger()
->callerRemove(__METHOD__);
}
/**
* {@inheritdoc}
*/
public function routeTypeToMethod($type) {
$methods = [
'tag' => 'invalidateTags',
'url' => 'invalidateUrls',
'everything' => 'invalidateEverything',
];
return isset($methods[$type]) ? $methods[$type] : 'invalidate';
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AcquiaPlatformCdnPurger:: |
protected | property | The Acquia Platform CDN backend. | |
AcquiaPlatformCdnPurger:: |
protected | property | The Guzzle HTTP client. | |
AcquiaPlatformCdnPurger:: |
protected | property | Information object interfacing with the Acquia platform. | |
AcquiaPlatformCdnPurger:: |
public static | function |
Creates an instance of the plugin. Overrides PurgerBase:: |
|
AcquiaPlatformCdnPurger:: |
public | function |
Indicates whether your purger utilizes dynamic runtime measurement. Overrides PurgerCapacityDataInterface:: |
|
AcquiaPlatformCdnPurger:: |
protected | function | Lazy load the underlying backend based on PlatformInfo CDN configuration. | |
AcquiaPlatformCdnPurger:: |
public | function |
Invalidate content from external caches. Overrides PurgerInterface:: |
|
AcquiaPlatformCdnPurger:: |
public | function | Invalidate the entire CDN. | |
AcquiaPlatformCdnPurger:: |
public | function | Invalidate a set of tag invalidations. | |
AcquiaPlatformCdnPurger:: |
public | function | Invalidate a set of URL invalidations. | |
AcquiaPlatformCdnPurger:: |
public | function |
Route certain type of invalidations to other methods. Overrides PurgerBase:: |
|
AcquiaPlatformCdnPurger:: |
final public | function |
Constructs a AcquiaCdnPurger object. Overrides PurgerBase:: |
|
DebuggerAwareTrait:: |
private | property | The debugger instance. | |
DebuggerAwareTrait:: |
public | function | ||
DebuggerAwareTrait:: |
public | function | ||
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PurgeLoggerAwareTrait:: |
protected | property | Channel logger. | |
PurgeLoggerAwareTrait:: |
public | function | ||
PurgerBase:: |
protected | property | Unique instance ID for this purger. | |
PurgerBase:: |
protected | property | The runtime measurement counter. | |
PurgerBase:: |
public | function |
The current instance of this purger plugin is about to be deleted. Overrides PurgerInterface:: |
1 |
PurgerBase:: |
public | function |
Get the time in seconds to wait after invalidation. Overrides PurgerCapacityDataInterface:: |
|
PurgerBase:: |
public | function |
Retrieve the unique instance ID for this purger instance. Overrides PurgerInterface:: |
|
PurgerBase:: |
public | function |
Get the maximum number of invalidations that this purger can process. Overrides PurgerCapacityDataInterface:: |
1 |
PurgerBase:: |
public | function |
Retrieve the user-readable label for this purger instance. Overrides PurgerInterface:: |
|
PurgerBase:: |
public | function |
Get the runtime measurement counter. Overrides PurgerCapacityDataInterface:: |
|
PurgerBase:: |
public | function |
Get the maximum number of seconds, processing a single invalidation takes. Overrides PurgerCapacityDataInterface:: |
|
PurgerBase:: |
public | function |
Retrieve the list of supported invalidation types. Overrides PurgerInterface:: |
|
PurgerBase:: |
public | function |
Inject the runtime measurement counter. Overrides PurgerCapacityDataInterface:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |