class DeployEndpoint in Deploy - Content Staging 7.3
Same name and namespace in other branches
- 7.2 includes/DeployEndpoint.inc \DeployEndpoint
Class representing a deployment endpoint.
Hierarchy
- class \DeployEndpoint
Expanded class hierarchy of DeployEndpoint
File
- includes/
DeployEndpoint.inc, line 10 - Base class for Deploy endpoint definitions.
View source
class DeployEndpoint {
/**
* Whether debug mode is enabled for this endpoint.
*
* @var boolean
*/
public $debug = FALSE;
/**
* The name of the service plugin to be used to deploy to this endpoint.
*
* @var string
*/
public $service_plugin = NULL;
/**
* An associative array of configuration settings to pass to the service
* object's constructor. Allowable keys will depend on the plugin being used.
*
* @var array
*/
public $service_config = array();
/**
* The service object that will be used to push to this endpoint.
*
* @var DeployService
*/
public $service = NULL;
/**
* The name of the authenticator plugin to be used for this endpoint.
*
* @var string
*/
public $authenticator_plugin = NULL;
/**
* An associative array of configuration settings to pass to the authenticator
* object's constructor. Allowable keys will depend on the plugin being used.
*
* @var array
*/
public $authenticator_config = array();
/**
* The authenticator object that will be used to push to this endpoint.
*
* @var DeployAuthenticator
*/
public $authenticator = NULL;
/**
* Loads the endpoint.
*/
public function load() {
// Since the CTools Export API is declarative by nature, we can't realy on
// contructor injection and deploy_endpoint_create() as the only factory.
if (!empty($this->service_plugin)) {
$service_config = $this->service_config + array(
'debug' => $this->debug,
);
$this->service = new $this->service_plugin($service_config);
}
if (!empty($this->authenticator_plugin)) {
$authenticator_config = $this->authenticator_config + array(
'debug' => $this->debug,
);
$this->authenticator = new $this->authenticator_plugin($this->service, $authenticator_config);
}
}
/**
* Deploys all entities over to the endpoint.
*
* @param string $lock_name
* The name of the lock that this deployment is working under.
* @param integer $deployment_key
* The unique deployment key for this deployment.
* @param Traversable $iterator
* Usually this will be an object from a subclass of DeployAggregatorBase.
* @param string $lock_name
* Optional name of the lock that this deployment is working under.
*/
public function deploy($deployment_key, Traversable $iterator, $lock_name = NULL) {
try {
if (empty($this->authenticator)) {
$this
->load();
}
$this->authenticator
->deploy($iterator);
deploy_log($deployment_key, DEPLOY_STATUS_DEPLOYED);
if (variable_get('deploy_audit_log', FALSE)) {
$this
->log_deployed_entities($deployment_key, $iterator);
}
} catch (Exception $e) {
if (!empty($lock_name)) {
lock_release($lock_name);
}
deploy_log($deployment_key, DEPLOY_STATUS_FAILED, $e);
throw $e;
}
}
/**
* Publishes all entities on the endpoint. Happens after deployment.
*
* @param string $lock_name
* The name of the lock that this deployment is working under.
* @param integer $deployment_key
* The unique deployment key for this deployment.
* @param Traversable $iterator
* Usually this will be an object from a subclass of DeployAggregatorBase.
* @param string $lock_name
* Optional name of the lock that this deployment is working under.
*/
public function publish($deployment_key, Traversable $iterator, $lock_name = NULL) {
try {
if (empty($this->authenticator)) {
$this
->load();
}
// Consider going through the authenticator here, as in self::deploy().
$this->service
->publish($iterator);
deploy_log($deployment_key, DEPLOY_STATUS_PUBLISHED);
module_invoke_all('deploy_plan_publish', DEPLOY_STATUS_PUBLISHED);
} catch (Exception $e) {
if (!empty($lock_name)) {
lock_release($lock_name);
}
deploy_log($deployment_key, DEPLOY_STATUS_FAILED, $e);
module_invoke_all('deploy_plan_publish', DEPLOY_STATUS_FAILED);
throw $e;
}
}
/**
* Logs to watchdog the list of deployed entities.
*
* @param interger $deployment_key
* The unique deployment key for this deployment.
* @param Traversable $iterator
* Usually this will be an object from a subclass of DeployAggregatorBase.
*/
public function log_deployed_entities($deployment_key, Traversable $iterator) {
$entities = [];
foreach ($iterator
->getEntities() as $key => $item) {
$entities[] = $item['type'] . ': ' . $item['id'];
}
watchdog('deployed_content', 'Deployed %deploy_key with entities:</br> %entities', array(
'%deploy_key' => $deployment_key,
'%entities' => implode(', ', $entities),
));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeployEndpoint:: |
public | property | The authenticator object that will be used to push to this endpoint. | |
DeployEndpoint:: |
public | property | An associative array of configuration settings to pass to the authenticator object's constructor. Allowable keys will depend on the plugin being used. | |
DeployEndpoint:: |
public | property | The name of the authenticator plugin to be used for this endpoint. | |
DeployEndpoint:: |
public | property | Whether debug mode is enabled for this endpoint. | |
DeployEndpoint:: |
public | property | The service object that will be used to push to this endpoint. | |
DeployEndpoint:: |
public | property | An associative array of configuration settings to pass to the service object's constructor. Allowable keys will depend on the plugin being used. | |
DeployEndpoint:: |
public | property | The name of the service plugin to be used to deploy to this endpoint. | |
DeployEndpoint:: |
public | function | Deploys all entities over to the endpoint. | |
DeployEndpoint:: |
public | function | Loads the endpoint. | |
DeployEndpoint:: |
public | function | Logs to watchdog the list of deployed entities. | |
DeployEndpoint:: |
public | function | Publishes all entities on the endpoint. Happens after deployment. |