public function AcsfSite::refresh in Acquia Cloud Site Factory Connector 8
Same name and namespace in other branches
- 8.2 src/AcsfSite.php \Drupal\acsf\AcsfSite::refresh()
Refreshes the site information from the Site Factory.
Parameters
array $data: (Optional) Data that should be sent to the factory.
Return value
bool Returns TRUE if the data fetch was successful.
1 call to AcsfSite::refresh()
- AcsfSite::clean in src/
AcsfSite.php - Removes all local information and refreshes data from the Factory.
File
- src/
AcsfSite.php, line 147
Class
- AcsfSite
- AcsfSite.
Namespace
Drupal\acsfCode
public function refresh(array $data = []) {
if (function_exists('is_acquia_host') && !is_acquia_host()) {
return FALSE;
}
try {
$site_id = !empty($this->site_id) ? $this->site_id : $GLOBALS['gardens_site_settings']['conf']['acsf_site_id'];
$arguments = [
'site_id' => $site_id,
'site_data' => $data,
];
$message = new AcsfMessageRest('GET', 'site-api/v1/sync/' . $site_id, $arguments);
$message
->send();
$site_info = $message
->getResponseBody();
} catch (AcsfMessageFailedResponseException $e) {
// No need to fail, we can retry the site info call.
}
if (empty($site_info)) {
\Drupal::logger('acsf_site')
->critical('Could not retrieve site information after installation.');
return FALSE;
}
else {
// Allow other modules to consume the data.
$context = $site_info;
$event = AcsfEvent::create('acsf_site_data_receive', $context);
$event
->run();
$this
->saveSiteInfo($site_info['sf_site']);
return TRUE;
}
}