function drush_acsf_site_sync in Acquia Cloud Site Factory Connector 8
Command callback. Synchronizes data with the Factory.
When executed without a --data option, this command will call the Factory to get data. When called with the --data option it will simply digest that data.
2 calls to drush_acsf_site_sync()
- drush_acsf_connect_factory in acsf_init/
acsf_init.drush.inc - Command callback: Connect a site to a Factory.
- drush_acsf_site_scrub in ./
acsf.drush.inc - Command callback. Scrubs the site database and/or other storage.
File
- ./
acsf.drush.inc, line 207 - Provides drush commands for site related operations.
Code
function drush_acsf_site_sync() {
$site = AcsfSite::load();
$data = drush_get_option('data', NULL);
// Create an event to gather site stats to send to the Factory.
$context = [];
$event = AcsfEvent::create('acsf_stats', $context);
$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);
$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);
}
}