Same name in other branches
- 5.0.x src/Form/InfoForm.php \Drupal\advagg\Form\InfoForm::getRandomFile()
- 6.0.x src/Form/InfoForm.php \Drupal\advagg\Form\InfoForm::getRandomFile()
- 8.x-3.x src/Form/InfoForm.php \Drupal\advagg\Form\InfoForm::getRandomFile()
Get a (pseudo) random optimized file name.
Return value
bool|string The filename or FALSE if no valid files found.
1 call to InfoForm::getRandomFile()
- InfoForm::buildForm dans src/
Form/ InfoForm.php
Fichier
-
src/
Form/ InfoForm.php, line 256
Classe
- InfoForm
- View AdvAgg information for this site.
Namespace
Drupal\advagg\FormCode
private function getRandomFile() {
// Ensure the directory exists.
$dir = 'public://js/optimized/';
if (!is_dir($dir)) {
return FALSE;
}
if ($handler = opendir($dir)) {
while (($file = readdir($handler)) !== FALSE) {
if (is_file($dir . $file) && pathinfo($file, PATHINFO_EXTENSION) == 'js') {
closedir($handler);
return $file;
}
}
closedir($handler);
}
return FALSE;
}