You are here

abstract class AcsfConfig in Acquia Cloud Site Factory Connector 8

Same name and namespace in other branches
  1. 8.2 src/AcsfConfig.php \Drupal\acsf\AcsfConfig

Provides an interface to define how our message configuration should work.

Hierarchy

Expanded class hierarchy of AcsfConfig

2 files declare their use of AcsfConfig
AcsfConfigUnitTest.inc in tests/AcsfConfigUnitTest.inc
AcsfConfigUnitTestMissingUsername.inc in tests/AcsfConfigUnitTestMissingUsername.inc

File

src/AcsfConfig.php, line 8

Namespace

Drupal\acsf
View source
abstract class AcsfConfig {

  /**
   * The URL of the remote service (factory).
   *
   * @var string
   */
  protected $url;

  /**
   * The username of the remote service.
   *
   * @var string
   */
  protected $username;

  /**
   * The password of the remote service.
   *
   * @var string
   */
  protected $password;

  /**
   * The optional signup suffix of the Factory. See getUrlSuffix() for caveat.
   *
   * @var string
   */
  protected $urlSuffix;

  /**
   * The optional source URL of the factory which our sites were staged from.
   *
   * @var string
   */
  protected $sourceUrl;

  /**
   * An optional Acquia Hosting sitegroup.
   *
   * @var string
   */
  protected $ahSite;

  /**
   * An optional Acquia Hosting environment.
   *
   * @var string
   */
  protected $ahEnv;

  /**
   * Constructor.
   *
   * @param string $ah_site
   *   (Optional) Acquia Hosting sitegroup.
   * @param string $ah_env
   *   (Optional) Acquia Hosting environment.
   *
   * @throws AcsfConfigIncompleteException
   */
  public function __construct($ah_site = NULL, $ah_env = NULL) {
    if (function_exists('is_acquia_host') && !is_acquia_host()) {
      return;
    }

    // If none specified, pick the site group and environment from $_ENV.
    if (empty($ah_site)) {
      $ah_site = $_ENV['AH_SITE_GROUP'];
    }
    if (empty($ah_env)) {
      $ah_env = $_ENV['AH_SITE_ENVIRONMENT'];
    }
    $this->ahSite = $ah_site;
    $this->ahEnv = $ah_env;
    $this
      ->loadConfig();

    // Require the loadConfig implementation to set required values.
    foreach ([
      'url',
      'username',
      'password',
    ] as $key) {
      if (empty($this->{$key})) {
        throw new AcsfConfigIncompleteException(sprintf('The ACSF configuration was incomplete, no value was found for %s.', $key));
      }
    }
  }

  /**
   * Retrieves the config username.
   */
  public function getUsername() {
    return $this->username;
  }

  /**
   * Retrieves the config password.
   */
  public function getPassword() {
    return $this->password;
  }

  /**
   * Retrieves the URL of the remote service (factory).
   */
  public function getUrl() {
    return $this->url;
  }

  /**
   * Retrieves the domain suffix used for sites hosted on this ACSF environment.
   *
   * Please note: this is not always equal to the suffix of the factory URL. In
   * practice it is, except when the site factory governs sites hosted in
   * multiple regions across the world. In that case, sites hosted in specific
   * regions have a specific domain suffix - which differs from the factory
   * URL for at least one region.
   *
   * This value is empty on production sites; it is only set for staged sites.
   */
  public function getUrlSuffix() {
    return $this->urlSuffix;
  }

  /**
   * Retrieves the URL of the production factory.
   *
   * This value is empty on production sites; it is only set for staged sites.
   */
  public function getSourceUrl() {
    return $this->sourceUrl;
  }

  /**
   * Loads the configuration.
   *
   * Client code MUST populate the url, username and password properties.
   */
  protected abstract function loadConfig();

}

Members

Namesort descending Modifiers Type Description Overrides
AcsfConfig::$ahEnv protected property An optional Acquia Hosting environment.
AcsfConfig::$ahSite protected property An optional Acquia Hosting sitegroup.
AcsfConfig::$password protected property The password of the remote service.
AcsfConfig::$sourceUrl protected property The optional source URL of the factory which our sites were staged from.
AcsfConfig::$url protected property The URL of the remote service (factory).
AcsfConfig::$urlSuffix protected property The optional signup suffix of the Factory. See getUrlSuffix() for caveat.
AcsfConfig::$username protected property The username of the remote service.
AcsfConfig::getPassword public function Retrieves the config password.
AcsfConfig::getSourceUrl public function Retrieves the URL of the production factory.
AcsfConfig::getUrl public function Retrieves the URL of the remote service (factory).
AcsfConfig::getUrlSuffix public function Retrieves the domain suffix used for sites hosted on this ACSF environment.
AcsfConfig::getUsername public function Retrieves the config username.
AcsfConfig::loadConfig abstract protected function Loads the configuration. 5
AcsfConfig::__construct public function Constructor.