function drush_hook_update_deploy_tools_site_deploy_init in Hook Update Deploy Tools 7
Same name and namespace in other branches
- 8 hook_update_deploy_tools.drush.inc \drush_hook_update_deploy_tools_site_deploy_init()
Drush command to create site_deploy module.
Parameters
string $directory_path: The path and name of the directory where site_deploy should be created.
File
- ./
hook_update_deploy_tools.drush.inc, line 167 - Drush commands for Hook Deploy Update Tools.
Code
function drush_hook_update_deploy_tools_site_deploy_init($directory_path = '../custom') {
// Check to see if site_deploy already exists in the site.
$exists = drupal_get_filename('module', 'site_deploy');
if ($exists) {
// site_deploy already exists. Error out.
$error = dt("The module site_deploy already exists at !location.", array(
'!location' => $exists,
));
drush_log($error, 'error');
}
else {
// Site_deploy does not exist, so proceed with making it.
$hudt_dir = drupal_get_path('module', 'hook_update_deploy_tools');
$hudt_dir = drush_normalize_path($hudt_dir);
$boilerplate_dir = "{$hudt_dir}/boilerplate";
// Check destination directory exists.
$destination = "{$hudt_dir}/../{$directory_path}";
$destination = drush_normalize_path($destination);
if (is_dir($destination)) {
// Make the directory site_deploy.
$made_dir = drush_mkdir("{$destination}/site_deploy", TRUE);
if ($made_dir) {
// Move the files.
drush_copy_dir("{$boilerplate_dir}/info.txt", "{$destination}/site_deploy/site_deploy.info", FILE_EXISTS_ABORT);
drush_copy_dir("{$boilerplate_dir}/install.php", "{$destination}/site_deploy/site_deploy.install", FILE_EXISTS_ABORT);
drush_copy_dir("{$boilerplate_dir}/module.php", "{$destination}/site_deploy/site_deploy.module", FILE_EXISTS_ABORT);
$success = dt("The module 'site_deploy' was created at '!location'", array(
'!location' => $destination,
));
drush_log($success, 'success');
}
}
else {
$error = dt("The destination of !destination does not seem to exist as a directory. It should be relative to where hook_update_deploy_tools is found.", array(
'!destination' => $destination,
));
drush_log($error, 'error');
}
}
}