AcquiaPlatformCdnTagsHeader.php in Acquia Purge 8
File
src/Plugin/Purge/TagsHeader/AcquiaPlatformCdnTagsHeader.php
View source
<?php
namespace Drupal\acquia_purge\Plugin\Purge\TagsHeader;
use Drupal\acquia_purge\AcquiaCloud\PlatformInfoInterface;
use Drupal\acquia_purge\AcquiaPlatformCdn\BackendFactory;
use Drupal\purge\Plugin\Purge\TagsHeader\TagsHeaderBase;
use Drupal\purge\Plugin\Purge\TagsHeader\TagsHeaderInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class AcquiaPlatformCdnTagsHeader extends TagsHeaderBase implements TagsHeaderInterface {
protected $backendClass = NULL;
protected $platformInfo;
public final function __construct(array $configuration, $plugin_id, $plugin_definition, PlatformInfoInterface $acquia_purge_platforminfo) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->platformInfo = $acquia_purge_platforminfo;
$this->backendClass = BackendFactory::getClass($this->platformInfo);
if ($this->backendClass) {
$this->backendClass::platformInfo($this->platformInfo);
}
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('acquia_purge.platforminfo'));
}
public function getHeaderName() {
if ($this->backendClass) {
return $this->backendClass::tagsHeaderName();
}
return $this
->getPluginDefinition()['header_name'];
}
public function getValue(array $tags) {
if ($this->backendClass) {
return $this->backendClass::tagsHeaderValue($tags);
}
return 'n/a';
}
public function isEnabled() {
if ($this->backendClass) {
return TRUE;
}
return FALSE;
}
}