public function AcsfExtraCommands::completeAsyncProcess in Acquia Cloud Site Factory Connector 8.2
Reports process completion back to the factory.
@command report-complete-async-process @bootstrap root @option data Serialized PHP data regarding the caller.
Parameters
array $options: The command options supplied to the executed command.
Throws
\Drupal\acsf\AcsfException; If the data argument is invalid.
File
- src/
Commands/ AcsfExtraCommands.php, line 189
Class
- AcsfExtraCommands
- Provides drush commands for site related operations.
Namespace
Drush\CommandsCode
public function completeAsyncProcess(array $options = [
'data' => NULL,
]) {
$data = unserialize($options['data']);
if (empty($data->callback) || empty($data->object_id) || empty($data->acsf_path)) {
throw new AcsfException(dt('Requires serialized object in --data argument with $data->callback and $data->object_id populated.'));
}
// Since this does not bootstrap drupal fully, we need to manually require
// the classes necessary to send a message to the Factory.
require_once $data->acsf_path . '/src/AcsfConfig.php';
require_once $data->acsf_path . '/src/AcsfConfigDefault.php';
require_once $data->acsf_path . '/src/AcsfConfigIncompleteException.php';
require_once $data->acsf_path . '/src/AcsfConfigMissingCredsException.php';
require_once $data->acsf_path . '/src/AcsfMessage.php';
require_once $data->acsf_path . '/src/AcsfMessageEmptyResponseException.php';
require_once $data->acsf_path . '/src/AcsfMessageFailedResponseException.php';
require_once $data->acsf_path . '/src/AcsfMessageFailureException.php';
require_once $data->acsf_path . '/src/AcsfMessageMalformedResponseException.php';
require_once $data->acsf_path . '/src/AcsfMessageRest.php';
require_once $data->acsf_path . '/src/AcsfMessageResponse.php';
require_once $data->acsf_path . '/src/AcsfMessageResponseRest.php';
$arguments = [
'wid' => $data->object_id,
'signal' => 1,
'state' => isset($data->state) ? $data->state : NULL,
'data' => $data,
];
try {
// We do not have a Drupal bootstrap at this point, so we need to use
// AcsfConfigDefault to obtain the shared credentials.
$config = new AcsfConfigDefault();
$message = new AcsfMessageRest('POST', $data->callback, $arguments, $config);
$message
->send();
} catch (\Exception $e) {
syslog(LOG_ERR, dt('Unable to contact the factory via AcsfMessage.'));
}
}