Commit 4c1aef9c authored by Niels van Mourik's avatar Niels van Mourik
Browse files

[QA] Changed HostingInfo into PlatformInfo to more accurately describe it.

parent 189a4563
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
services:
  acquia_purge.hostinginfo:
    class: Drupal\acquia_purge\AcquiaCloud\HostingInfo
  acquia_purge.platforminfo:
    class: Drupal\acquia_purge\AcquiaCloud\PlatformInfo
    arguments: ['@request_stack', '@settings', '@state']
    public: true
  http_client_middleware.acquia_purge_balancer_middleware:
+4 −4
Original line number Diff line number Diff line
@@ -8,9 +8,9 @@ use Drupal\Core\State\StateInterface;
use Symfony\Component\HttpFoundation\RequestStack;

/**
 * Provides a API to retrieve technical information from Acquia Cloud.
 * Provides an information object interfacing with the Acquia platform.
 */
class HostingInfo implements HostingInfoInterface {
class PlatformInfo implements PlatformInfoInterface {

  /**
   * Name of the PHP function that's available when on Acquia Cloud.
@@ -47,7 +47,7 @@ class HostingInfo implements HostingInfoInterface {
  protected $platformCdn = [];

  /**
   * Whether the current hosting environment is Acquia Cloud or not.
   * Whether the current site is running on Acquia Cloud or not.
   *
   * @var bool
   */
@@ -89,7 +89,7 @@ class HostingInfo implements HostingInfoInterface {
  protected $sitePath = '';

  /**
   * Constructs a HostingInfo object.
   * Constructs a PlatformInfo object.
   *
   * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
   *   The request stack.
+3 −3
Original line number Diff line number Diff line
@@ -3,9 +3,9 @@
namespace Drupal\acquia_purge\AcquiaCloud;

/**
 * Describes a API to retrieve technical information from Acquia Cloud.
 * Describes an information object interfacing with the Acquia platform.
 */
interface HostingInfoInterface {
interface PlatformInfoInterface {

  /**
   * Get the load balancer IP adresses installed in front of this site.
@@ -79,7 +79,7 @@ interface HostingInfoInterface {
  public function getSitePath();

  /**
   * Determine whether the current hosting environment is Acquia Cloud or not.
   * Determine whether the current site is running on Acquia Cloud.
   *
   * @return true|false
   *   Boolean expression where 'true' indicates Acquia Cloud or 'false'.
+14 −14
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@

namespace Drupal\acquia_purge\AcquiaPlatformCdn;

use Drupal\acquia_purge\AcquiaCloud\HostingInfoInterface;
use Drupal\acquia_purge\AcquiaCloud\PlatformInfoInterface;
use Drupal\acquia_purge\Plugin\Purge\Purger\DebuggerAwareTrait;
use Drupal\acquia_purge\Plugin\Purge\Purger\DebuggerInterface;
use Drupal\purge\Logger\LoggerChannelPartInterface;
@@ -25,24 +25,24 @@ abstract class BackendBase implements BackendInterface {
   * Acquia Platform CDN configuration settings.
   *
   * Associative array with arbitrary settings coming from:
   * \Drupal\acquia_purge\AcquiaCloud\HostingInfoInterface::getPlatformCdnConfiguration.
   * \Drupal\acquia_purge\AcquiaCloud\PlatformInfoInterface::getPlatformCdnConfiguration.
   *
   * @var array
   */
  protected $config;

  /**
   * API to retrieve technical information from Acquia Cloud.
   * Information object interfacing with the Acquia platform.
   *
   * @var \Drupal\acquia_purge\AcquiaCloud\HostingInfoInterface
   * @var \Drupal\acquia_purge\AcquiaCloud\PlatformInfoInterface
   */
  protected $hostingInfo;
  protected $platformInfo;

  /**
   * {@inheritdoc}
   */
  public function __construct(array $config, HostingInfoInterface $acquia_purge_hostinginfo, LoggerChannelPartInterface $logger, DebuggerInterface $debugger, ClientInterface $http_client) {
    $this->hostingInfo = $acquia_purge_hostinginfo;
  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;
@@ -62,15 +62,15 @@ abstract class BackendBase implements BackendInterface {
  /**
   * {@inheritdoc}
   */
  public static function hostingInfo(HostingInfoInterface $set = NULL) {
    static $hostinginfo;
    if (is_null($hostinginfo) && (!is_null($set))) {
      $hostinginfo = $set;
  public static function platformInfo(PlatformInfoInterface $set = NULL) {
    static $platforminfo;
    if (is_null($platforminfo) && (!is_null($set))) {
      $platforminfo = $set;
    }
    elseif (is_null($hostinginfo)) {
      throw new \RuntimeException("BackendBase::hostingInfo can't deliver requested instance.");
    elseif (is_null($platforminfo)) {
      throw new \RuntimeException("BackendBase::platformInfo can't deliver requested instance.");
    }
    return $hostinginfo;
    return $platforminfo;
  }

  /**
+16 −16
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@

namespace Drupal\acquia_purge\AcquiaPlatformCdn;

use Drupal\acquia_purge\AcquiaCloud\HostingInfoInterface;
use Drupal\acquia_purge\AcquiaCloud\PlatformInfoInterface;
use Drupal\acquia_purge\Plugin\Purge\Purger\DebuggerInterface;
use Drupal\purge\Logger\LoggerChannelPartInterface;
use GuzzleHttp\ClientInterface;
@@ -24,8 +24,8 @@ class BackendFactory {
  /**
   * Get a instantiated Platform CDN purger backend.
   *
   * @param \Drupal\acquia_purge\AcquiaCloud\HostingInfoInterface $hostinginfo
   *   Technical information accessors for the Acquia Cloud environment.
   * @param \Drupal\acquia_purge\AcquiaCloud\PlatformInfoInterface $platforminfo
   *   Information object interfacing with the Acquia platform.
   * @param \Drupal\purge\Logger\LoggerChannelPartInterface $logger
   *   The logger passed to the Platform CDN purger.
   * @param \Drupal\acquia_purge\Plugin\Purge\Purger\DebuggerInterface $debugger
@@ -36,8 +36,8 @@ class BackendFactory {
   * @return null|\Drupal\acquia_purge\AcquiaPlatformCdn\BackendInterface
   *   The instantiated backend or NULL in case of failure.
   */
  public static function get(HostingInfoInterface $hostinginfo, LoggerChannelPartInterface $logger, DebuggerInterface $debugger, ClientInterface $http_client) {
    if (!$backend_config = self::getConfig($hostinginfo)) {
  public static function get(PlatformInfoInterface $platforminfo, LoggerChannelPartInterface $logger, DebuggerInterface $debugger, ClientInterface $http_client) {
    if (!$backend_config = self::getConfig($platforminfo)) {
      return NULL;
    }
    if (!$backend_class = self::getClassFromConfig($backend_config)) {
@@ -48,7 +48,7 @@ class BackendFactory {
    }
    return new $backend_class(
      $backend_config,
      $hostinginfo,
      $platforminfo,
      $logger,
      $debugger,
      $http_client
@@ -58,17 +58,17 @@ class BackendFactory {
  /**
   * Get the CDN configuration array.
   *
   * @param \Drupal\acquia_purge\AcquiaCloud\HostingInfoInterface $hostinginfo
   *   Technical information accessors for the Acquia Cloud environment.
   * @param \Drupal\acquia_purge\AcquiaCloud\PlatformInfoInterface $platforminfo
   *   Information object interfacing with the Acquia platform.
   *
   * @return array|null
   *   NULL when unconfigured, or associative array with arbitrary settings
   *   coming from:
   *   \Drupal\acquia_purge\AcquiaCloud\HostingInfoInterface::getPlatformCdnConfiguration
   *   \Drupal\acquia_purge\AcquiaCloud\PlatformInfoInterface::getPlatformCdnConfiguration
   */
  public static function getConfig(HostingInfoInterface $hostinginfo) {
  public static function getConfig(PlatformInfoInterface $platforminfo) {
    try {
      return $hostinginfo->getPlatformCdnConfiguration();
      return $platforminfo->getPlatformCdnConfiguration();
    }
    catch (\RuntimeException $e) {
      return NULL;
@@ -76,16 +76,16 @@ class BackendFactory {
  }

  /**
   * Get the backend class based on hosting configuration.
   * Get the backend class based on platform configuration.
   *
   * @param \Drupal\acquia_purge\AcquiaCloud\HostingInfoInterface $hostinginfo
   *   Technical information accessors for the Acquia Cloud environment.
   * @param \Drupal\acquia_purge\AcquiaCloud\PlatformInfoInterface $platforminfo
   *   Information object interfacing with the Acquia platform.
   *
   * @return string|null
   *   Class providing the Platform CDN purger backend, or NULL if unconfigured.
   */
  public static function getClass(HostingInfoInterface $hostinginfo) {
    if ($config = self::getConfig($hostinginfo)) {
  public static function getClass(PlatformInfoInterface $platforminfo) {
    if ($config = self::getConfig($platforminfo)) {
      return self::getClassFromConfig($config);
    }
    return NULL;
Loading