You are here

class AutoConnector in Acquia Connector 3.x

Same name and namespace in other branches
  1. 8.2 src/AutoConnector.php \Drupal\acquia_connector\AutoConnector
  2. 8 src/AutoConnector.php \Drupal\acquia_connector\AutoConnector

Subscription Auto connector storage.

@package Drupal\acquia_connector.

Hierarchy

Expanded class hierarchy of AutoConnector

2 files declare their use of AutoConnector
acquia_connector.module in ./acquia_connector.module
Acquia Connector module.
AutoConnectorTest.php in tests/src/Unit/AutoConnectorTest.php

File

src/AutoConnector.php, line 12

Namespace

Drupal\acquia_connector
View source
class AutoConnector {

  /**
   * Holds Subscription.
   *
   * @var Subscription
   */
  protected $subscription;

  /**
   * Holds Storage.
   *
   * @var \Drupal\acquia_connector\Helper\Storage
   */
  protected $storage;

  /**
   * Holds global config.
   *
   * @var array
   */
  protected $globalConfig;

  /**
   * AutoConnector constructor.
   *
   * @param \Drupal\acquia_connector\Subscription $subscription
   *   Acquia Subscription.
   * @param \Drupal\acquia_connector\Helper\Storage $storage
   *   Storage.
   * @param array $global_config
   *   Global config.
   */
  public function __construct(Subscription $subscription, Storage $storage, array $global_config) {
    $this->subscription = $subscription;
    $this->storage = $storage;
    $this->globalConfig = $global_config;
  }

  /**
   * Ensures a connection to Acquia Subscription.
   *
   * @return mixed
   *   False or whatever is returned by Subscription::update.
   */
  public function connectToAcquia() {
    if ($this->subscription
      ->hasCredentials()) {
      return FALSE;
    }
    if (empty($this->globalConfig['ah_network_key'])) {
      return FALSE;
    }
    if (empty($this->globalConfig['ah_network_identifier'])) {
      return FALSE;
    }
    $this->storage
      ->setKey($this->globalConfig['ah_network_key']);
    $this->storage
      ->setIdentifier($this->globalConfig['ah_network_identifier']);
    return $this->subscription
      ->update();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AutoConnector::$globalConfig protected property Holds global config.
AutoConnector::$storage protected property Holds Storage.
AutoConnector::$subscription protected property Holds Subscription.
AutoConnector::connectToAcquia public function Ensures a connection to Acquia Subscription.
AutoConnector::__construct public function AutoConnector constructor.