You are here

private static function ScanDir::findContents in Gutenberg 8

Same name and namespace in other branches
  1. 8.2 src/ScanDir.php \Drupal\gutenberg\ScanDir::findContents()

This is how we scan directories.

1 call to ScanDir::findContents()
ScanDir::verifyPaths in src/ScanDir.php
Verifies paths.

File

src/ScanDir.php, line 109

Class

ScanDir
Class ScanDir.

Namespace

Drupal\gutenberg

Code

private static function findContents($dir) {
  $result = [];
  $root = scandir($dir);
  foreach ($root as $value) {
    if ($value === '.' || $value === '..') {
      continue;
    }
    if (is_file($dir . DIRECTORY_SEPARATOR . $value)) {
      if (!self::$extFilter || in_array(strtolower(pathinfo($dir . DIRECTORY_SEPARATOR . $value, PATHINFO_EXTENSION)), self::$extFilter)) {
        self::$files[] = $result[] = $dir . DIRECTORY_SEPARATOR . $value;
      }
      continue;
    }
    if (self::$recursive) {
      foreach (self::findContents($dir . DIRECTORY_SEPARATOR . $value) as $value) {
        self::$files[] = $result[] = $value;
      }
    }
  }

  // Return required for recursive search.
  return $result;
}