You are here

abstract class BackendBase in Acquia Purge 8

Provides a backend for the Platform CDN purger.

Hierarchy

Expanded class hierarchy of BackendBase

File

src/AcquiaPlatformCdn/BackendBase.php, line 14

Namespace

Drupal\acquia_purge\AcquiaPlatformCdn
View source
abstract class BackendBase implements BackendInterface {
  use DebuggerAwareTrait;

  /**
   * The Guzzle HTTP client.
   *
   * @var \GuzzleHttp\ClientInterface
   */
  protected $httpClient;

  /**
   * Acquia Platform CDN configuration settings.
   *
   * Associative array with arbitrary settings coming from:
   * \Drupal\acquia_purge\AcquiaCloud\PlatformInfoInterface::getPlatformCdnConfiguration.
   *
   * @var array
   */
  protected $config;

  /**
   * Information object interfacing with the Acquia platform.
   *
   * @var \Drupal\acquia_purge\AcquiaCloud\PlatformInfoInterface
   */
  protected $platformInfo;

  /**
   * {@inheritdoc}
   */
  public function __construct(array $config, PlatformInfoInterface $acquia_purge_platforminfo, LoggerChannelPartInterface $logger, DebuggerInterface $debugger, ClientInterface $http_client) {
    $this->platformInfo = $acquia_purge_platforminfo;
    $this->httpClient = $http_client;
    $this->logger = $logger;
    $this->config = $config;
    $this
      ->setDebugger($debugger);
  }

  /**
   * {@inheritdoc}
   */
  public static function getTemporaryRuntimeError() {
    if ($error = \Drupal::cache()
      ->get('acquia_purge_cdn_runtime_error')) {
      return $error->data;
    }
    return '';
  }

  /**
   * {@inheritdoc}
   */
  public static function platformInfo(PlatformInfoInterface $set = NULL) {
    static $platforminfo;
    if (is_null($platforminfo) && !is_null($set)) {
      $platforminfo = $set;
    }
    elseif (is_null($platforminfo)) {
      throw new \RuntimeException("BackendBase::platformInfo can't deliver requested instance.");
    }
    return $platforminfo;
  }

  /**
   * {@inheritdoc}
   */
  public static function setTemporaryRuntimeError($message, $timeout = 300) {
    \Drupal::cache()
      ->set('acquia_purge_cdn_runtime_error', $message, time() + $timeout);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BackendBase::$config protected property Acquia Platform CDN configuration settings.
BackendBase::$httpClient protected property The Guzzle HTTP client.
BackendBase::$platformInfo protected property Information object interfacing with the Acquia platform.
BackendBase::getTemporaryRuntimeError public static function Check if a temporary runtime error has been set. Overrides BackendInterface::getTemporaryRuntimeError
BackendBase::platformInfo public static function Get the information object interfacing with the Acquia platform. Overrides BackendInterface::platformInfo
BackendBase::setTemporaryRuntimeError public static function Set a temporary runtime error. Overrides BackendInterface::setTemporaryRuntimeError
BackendBase::__construct public function Construct a vendor backend for the Platform CDN purger. Overrides BackendInterface::__construct 1
BackendInterface::invalidateEverything public function Invalidate all 'everything' invalidations. 1
BackendInterface::invalidateTags public function Invalidate all 'tag' invalidations. 1
BackendInterface::invalidateUrls public function Invalidate all 'url' invalidations. 1
BackendInterface::tagsHeaderName public static function Fetch the HTTP response header name that the CDN vendor needs. 1
BackendInterface::tagsHeaderValue public static function Format the given cache tags for the header value representation. 1
BackendInterface::validateConfiguration public static function Validate the configuration array given. 1
DebuggerAwareTrait::$debuggerInstance private property The debugger instance.
DebuggerAwareTrait::debugger public function
DebuggerAwareTrait::setDebugger public function
PurgeLoggerAwareTrait::$logger protected property Channel logger.
PurgeLoggerAwareTrait::logger public function