Skip to content
Snippets Groups Projects
Commit 843d7d66 authored by Angie Byron's avatar Angie Byron
Browse files

Issue #2138239 by damiankloip, tim.plunkett, amateescu: Use GlobIterator instead of glob.

parent 956c27fd
No related branches found
No related tags found
No related merge requests found
......@@ -204,14 +204,11 @@ public function listAll($prefix = '') {
throw new StorageException($this->directory . '/ not found.');
}
$extension = '.' . static::getFileExtension();
$files = new \GlobIterator(DRUPAL_ROOT . '/' . $this->directory . '/' . $prefix . '*' . $extension);
$names = array();
foreach ($files as $file) {
$names[] = $file->getBasename($extension);
}
return $names;
$files = glob($this->directory . '/' . $prefix . '*' . $extension);
$clean_name = function ($value) use ($extension) {
return basename($value, $extension);
};
return array_map($clean_name, $files);
}
/**
......
......@@ -134,9 +134,10 @@ public function getComponentNames($type, array $list) {
foreach ($list as $name) {
$directory = $this->getComponentFolder($type, $name);
if (file_exists($directory)) {
$files = new \GlobIterator(DRUPAL_ROOT . '/' . $directory . '/*' . $extension);
foreach ($files as $file) {
$folders[$file->getBasename($extension)] = $directory;
$files = glob($directory . '/*' . $extension);
foreach ($files as $filename) {
$name = basename($filename, $extension);
$folders[$name] = $directory;
}
}
}
......
......@@ -320,9 +320,9 @@ public function getLangcodes() {
if (empty($langcodes)) {
$langcodes = array();
// Collect languages included with CKEditor based on file listing.
$ckeditor_languages = new \GlobIterator(DRUPAL_ROOT . '/core/assets/vendor/ckeditor/lang/*.js');
foreach ($ckeditor_languages as $language_file) {
$langcode = $language_file->getBasename('.js');
$ckeditor_languages = glob(DRUPAL_ROOT . '/core/assets/vendor/ckeditor/lang/*.js');
foreach ($ckeditor_languages as $language_filename) {
$langcode = basename($language_filename, '.js');
$langcodes[$langcode] = $langcode;
}
cache('ckeditor.languages')->set('langcodes', $langcodes);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment