Same name in other branches
- 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()
- 8.x-4.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 in src/
Form/ InfoForm.php
File
-
src/
Form/ InfoForm.php, line 256
Class
- 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;
}