Same name and namespace in other branches
- 5.0.x modules/views_slideshow_cycle/src/Commands/ViewsSlideshowCycleCommands.php \Drupal\views_slideshow_cycle\Commands\ViewsSlideshowCycleCommands::installLibrary()
Helper function to download a library in the given directory.
4 calls to ViewsSlideshowCycleCommands::installLibrary()
- ViewsSlideshowCycleCommands::downloadCycle in modules/
views_slideshow_cycle/ src/ Commands/ ViewsSlideshowCycleCommands.php - Download and install the jQuery Cycle library.
- ViewsSlideshowCycleCommands::downloadHoverIntent in modules/
views_slideshow_cycle/ src/ Commands/ ViewsSlideshowCycleCommands.php - Download and install the jquery.hoverIntent library.
- ViewsSlideshowCycleCommands::downloadJson2 in modules/
views_slideshow_cycle/ src/ Commands/ ViewsSlideshowCycleCommands.php - Download and install the JSON2 library.
- ViewsSlideshowCycleCommands::downloadPause in modules/
views_slideshow_cycle/ src/ Commands/ ViewsSlideshowCycleCommands.php - Download and install the jQuery.pause library.
File
-
modules/
views_slideshow_cycle/ src/ Commands/ ViewsSlideshowCycleCommands.php, line 91
Class
- ViewsSlideshowCycleCommands
- Drush commands for Views Slideshow Cycle.
Namespace
Drupal\views_slideshow_cycle\CommandsCode
protected function installLibrary($name, $path, $filename, $url) {
// Create the path if it does not exist.
if (!is_dir($path)) {
drush_op('mkdir', $path, 0755, TRUE);
$this->logger()
->info(dt('Directory @path was created', [
'@path' => $path,
]));
}
// Be sure we can write in the directory.
$perms = substr(sprintf('%o', fileperms($path)), -4);
if ($perms !== '0755') {
Drush::process('chmod 755 ' . $path);
}
else {
$perms = NULL;
}
$dir = getcwd();
// Download the JavaScript file.
if (is_file($path . '/' . $filename)) {
$this->logger()
->notice(dt('@name appears to be already installed.', [
'@name' => $name,
]));
}
elseif (drush_op('chdir', $path) && Drush::process('wget ' . $url)) {
$this->logger()
->success(dt('The latest version of @name has been downloaded to @path', [
'@name' => $name,
'@path' => $path,
]));
}
else {
$this->logger()
->warning(dt('Drush was unable to download the @name library to @path', [
'@name' => $name,
'@path' => $path,
]));
}
chdir($dir);
// Restore the previous permissions.
if ($perms) {
Drush::process('chmod ' . $perms . ' ' . $path);
}
}