function drush_hook_update_deploy_tools_site_deploy_import in Hook Update Deploy Tools 7
Drush command to import anything that implements the ImportInterface.
Parameters
string $type: The type of thing to import Rules, Menus... must match HUDT class name.
string $machine_name: The machine name or unique identifier of the item to import.
File
- ./
hook_update_deploy_tools.drush.inc, line 262 - Drush commands for Hook Deploy Update Tools.
Code
function drush_hook_update_deploy_tools_site_deploy_import($type, $machine_name) {
try {
$msg = array();
$alter_plurals = array(
'Rule' => 'Rules',
'Node' => 'Nodes',
);
$type = !empty($alter_plurals[$type]) ? $alter_plurals[$type] : $type;
// Check to see if the class exists.
$class = '\\HookUpdateDeployTools\\' . $type;
\HookUpdateDeployTools\Check::classExists($class);
// Check that we are dealing with an importable type (an ImportInterface).
$implements = class_implements($class);
if (is_array($implements) && in_array('HookUpdateDeployTools\\ImportInterface', $implements)) {
// Check that we have what it needs to import.
$class::canImport();
// It can import so can safely proceed.
$msg = dt('Imported') . " {$type}: [{$machine_name}] => " . $class::import($machine_name);
}
else {
// It does not implement ImportInterface. Throw an exception.
$msg = '\\HookUpdateDeployTools\\@type does not implement ImportInterface so this command can not be called.';
$vars = array(
'@type' => $type,
);
throw new \HookUpdateDeployTools\HudtException($msg, $vars, WATCHDOG_ERROR, FALSE);
}
} catch (\Exception $e) {
// Any errors from this drush command do not need to be watchdog logged.
$e->logIt = FALSE;
$vars = array(
'@error' => method_exists($e, 'logMessage') ? $e
->logMessage() : $e
->getMessage(),
);
$msg = dt("site-deploy-import Caught exception: @error", $vars);
drush_log($msg, 'error');
// Clear out the $msg so it is not duplicated in the return.
$msg = '';
}
return $msg;
}