You are here

private static function ScanDir::findContents in Gutenberg 8.2

Same name and namespace in other branches
  1. 8 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 133

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 $entry) {
        self::$files[] = $result[] = $entry;
      }
    }
  }

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