class AutoConnector in Acquia Connector 3.x
Same name and namespace in other branches
- 8.2 src/AutoConnector.php \Drupal\acquia_connector\AutoConnector
- 8 src/AutoConnector.php \Drupal\acquia_connector\AutoConnector
Subscription Auto connector storage.
@package Drupal\acquia_connector.
Hierarchy
- class \Drupal\acquia_connector\AutoConnector
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_connectorView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AutoConnector:: |
protected | property | Holds global config. | |
AutoConnector:: |
protected | property | Holds Storage. | |
AutoConnector:: |
protected | property | Holds Subscription. | |
AutoConnector:: |
public | function | Ensures a connection to Acquia Subscription. | |
AutoConnector:: |
public | function | AutoConnector constructor. |