Same name and namespace in other branches
- 8.x-4.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.
Paramètres
string $name: The user friendly name of the download.
string $path: The directory to download to.
string $filename: The filename to expect.
string $url: The url to download the file from.
4 calls to ViewsSlideshowCycleCommands::installLibrary()
- ViewsSlideshowCycleCommands::downloadCycle dans modules/
views_slideshow_cycle/ src/ Commands/ ViewsSlideshowCycleCommands.php - Download and install the jQuery Cycle library.
- ViewsSlideshowCycleCommands::downloadHoverIntent dans modules/
views_slideshow_cycle/ src/ Commands/ ViewsSlideshowCycleCommands.php - Download and install the jquery.hoverIntent library.
- ViewsSlideshowCycleCommands::downloadJson2 dans modules/
views_slideshow_cycle/ src/ Commands/ ViewsSlideshowCycleCommands.php - Download and install the JSON2 library.
- ViewsSlideshowCycleCommands::downloadPause dans modules/
views_slideshow_cycle/ src/ Commands/ ViewsSlideshowCycleCommands.php - Download and install the jQuery.pause library.
Fichier
-
modules/
views_slideshow_cycle/ src/ Commands/ ViewsSlideshowCycleCommands.php, line 101
Classe
- ViewsSlideshowCycleCommands
- Drush commands for Views Slideshow Cycle.
Namespace
Drupal\views_slideshow_cycle\CommandsCode
protected function installLibrary(string $name, string $path, string $filename, string $url) : void {
// 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') {
$this->processManager()
->process([
'chmod',
755,
$path,
])
->start();
}
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,
]));
}
$download = $this->processManager()
->process([
'wget',
$url,
], $path);
$download->start();
if ($download->wait() === 0) {
$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, error: @error', [
'@name' => $name,
'@path' => $path,
'@error' => $download->getErrorOutput(),
]));
}
chdir($dir);
// Restore the previous permissions.
if ($perms) {
$this->processManager()
->process([
'chmod',
$perms,
$path,
])
->start();
}
}