function drush_kraken_library in Kraken 7
Same name and namespace in other branches
- 7.2 drush/kraken.drush.inc \drush_kraken_library()
Command to download the kraken library.
1 string reference to 'drush_kraken_library'
- kraken_drush_command in drush/
kraken.drush.inc - Implementation of hook_drush_command().
File
- drush/
kraken.drush.inc, line 69 - drush integration for kraken.
Code
function drush_kraken_library() {
$args = func_get_args();
if (!empty($args[0])) {
$path = $args[0];
}
else {
$path = 'sites/all/libraries';
}
// Create the path if it does not exist.
if (!is_dir($path)) {
drush_op('mkdir', $path);
drush_log(dt('Directory @path was created', array(
'@path' => $path,
)), 'notice');
}
// Set the directory to the download location.
$olddir = getcwd();
chdir($path);
// Download the zip archive.
if ($filepath = drush_download_file(KRAKEN_DOWNLOAD_URI)) {
$filename = basename($filepath);
$dirname = 'kraken-php-master';
// Remove any existing kraken library directory.
if (is_dir($dirname) || is_dir('kraken-php')) {
drush_delete_dir($dirname, TRUE);
drush_delete_dir('kraken-php', TRUE);
drush_log(dt('An existing kraken library was deleted from @path', array(
'@path' => $path,
)), 'notice');
}
// Decompress the zip archive.
drush_tarball_extract($filename);
// Change the directory name to "kraken-php" if needed.
if ($dirname != 'kraken-php') {
drush_move_dir($dirname, 'kraken-php', TRUE);
$dirname = 'kraken-php';
}
}
if (is_dir($dirname)) {
drush_log(dt('kraken library has been installed in @path', array(
'@path' => $path,
)), 'success');
}
else {
drush_log(dt('Drush was unable to install the kraken library to @path', array(
'@path' => $path,
)), 'error');
}
// Set working directory back to the previous working directory.
chdir($olddir);
}