Same name and namespace in other branches
  1. 5.0.x src/Form/InfoForm.php \Drupal\advagg\Form\InfoForm::getRandomFile() 1 commentaire
  2. 8.x-3.x src/Form/InfoForm.php \Drupal\advagg\Form\InfoForm::getRandomFile() 1 commentaire
  3. 8.x-4.x src/Form/InfoForm.php \Drupal\advagg\Form\InfoForm::getRandomFile() 1 commentaire

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 235

Classe

InfoForm
View AdvAgg information for this site.

Namespace

Drupal\advagg\Form

Code

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;
}