public function AcsfCommands::siteSync in Acquia Cloud Site Factory Connector 8.2
Synchronize data with the Factory.
@command acsf-site-sync @bootstrap database @option data A base64 encoded php array describing the site generated from the Factory.
Parameters
array $options: The command options supplied to the executed command.
File
- src/
Commands/ AcsfCommands.php, line 64
Class
- AcsfCommands
- Provides drush commands for site related operations.
Namespace
Drupal\acsf\CommandsCode
public function siteSync(array $options = [
'data' => NULL,
]) {
$site = AcsfSite::load();
$data = $options['data'];
// Create an event to gather site stats to send to the Factory.
$context = [];
$event = AcsfEvent::create('acsf_stats', $context, $this
->output());
$event
->run();
$stats = $event->context;
if ($data) {
// If data was sent, we can consume it here. Ensure that we are always
// passing associative arrays here, not objects.
$site_info = json_decode(base64_decode($data), TRUE);
if (!empty($site_info) && is_array($site_info)) {
// Allow other modules to consume the data.
$context = $site_info;
$event = AcsfEvent::create('acsf_site_data_receive', $context, $this
->output());
$event
->run();
// For debugging purpose to be able to tell if the data has been pulled
// or pushed.
$site->last_sf_push = time();
$site
->saveSiteInfo($site_info['sf_site']);
}
}
else {
// If no data was sent, we'll request it.
$site
->refresh($stats);
}
}