diff --git a/src/Halcyon/Datasource/FileDatasource.php b/src/Halcyon/Datasource/FileDatasource.php index b8cd59278..014ecfec4 100644 --- a/src/Halcyon/Datasource/FileDatasource.php +++ b/src/Halcyon/Datasource/FileDatasource.php @@ -34,6 +34,11 @@ class FileDatasource extends Datasource */ protected $resolvedBasePaths = []; + /** + * The maximum depth of the filesystem to scan, defaulting to 1 subdirectory. + */ + protected int $maxDepth = 1; + /** * Create a new datasource instance. * @@ -98,7 +103,7 @@ public function select(string $dirName, array $options = []): array } $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirPath)); - $it->setMaxDepth(1); // Support only a single level of subdirectories + $it->setMaxDepth($this->maxDepth); $it->rewind(); while ($it->valid()) { @@ -337,6 +342,10 @@ public function getAvailablePaths(): array ? new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->basePath)) : []; + if (!is_array($it)) { + $it->setMaxDepth($this->maxDepth + 1); + } + foreach ($it as $file) { if ($file->isDir()) { continue;