function hosting_site_drush_context_import in Hosting 7.3
Same name and namespace in other branches
- 6.2 site/hosting_site.drush.inc \hosting_site_drush_context_import()
- 7.4 site/hosting_site.drush.inc \hosting_site_drush_context_import()
Implements hook_drush_context_import().
File
- site/
hosting_site.drush.inc, line 38 - Drush hooks for the Hosting site module.
Code
function hosting_site_drush_context_import($context, &$node) {
if ($context->type == 'site') {
if (!isset($node->title)) {
$node->title = hosting_site_get_domain($context->uri);
// force lowercase for existing uri
}
$node->site_language = $context->language;
$node->cron_key = $context->cron_key;
$node->db_server = hosting_context_nid($context->db_server->name);
$node->platform = hosting_context_nid($context->platform->name);
// TODO: abstract this to remove duplication with import post hooks.
$profile = hosting_package_instance_load(array(
'i.rid' => $node->platform,
'p.short_name' => $context->profile,
));
if (!$profile) {
// For D6 to D7 upgrades, try changing default to standard.
if (!empty($context->profile) && $context->profile == 'default') {
$profile = hosting_package_instance_load(array(
'i.rid' => $node->platform,
'p.short_name' => 'standard',
));
if ($profile) {
drush_log(dt("Could not find the Profile !profile for Platfrom ID !platform, substituted standard", array(
'!profile' => $context->profile,
'!platform' => $node->platform,
)), 'warning');
}
}
}
// Log an error if there is still no profile.
if (!$profile) {
drush_set_error("HOSTING_SITE_IMPORT_ERROR", dt("Could not find the Profile !profile for Platfrom ID !platform", array(
'!profile' => $context->profile,
'!platform' => $node->platform,
)));
}
$node->profile = $profile->package_id;
$client = node_load(HOSTING_DEFAULT_CLIENT);
if ($context->client_name) {
$client = hosting_import_client($context->client_name);
}
$node->client = $client->nid;
}
}