Scanner.php in Default Content for D8 8
File
src/Scanner.php
View source
<?php
namespace Drupal\default_content;
class Scanner implements ScannerInterface {
public function scan($directory) {
$flags = \FilesystemIterator::UNIX_PATHS;
$flags |= \FilesystemIterator::SKIP_DOTS;
$flags |= \FilesystemIterator::CURRENT_AS_SELF;
$directory_iterator = new \RecursiveDirectoryIterator($directory, $flags);
$iterator = new \RecursiveIteratorIterator($directory_iterator);
$files = [];
foreach ($iterator as $fileinfo) {
if ($fileinfo
->isDir() || $fileinfo
->getExtension() != 'json') {
continue;
}
$file = new \stdClass();
$file->name = $fileinfo
->getFilename();
$file->uri = $fileinfo
->getPathname();
$files[$file->uri] = $file;
}
return $files;
}
}
Classes
Name |
Description |
Scanner |
A scanner to find YAML files in a given folder. |