acceptTests example



  /** * {@inheritdoc} */
  #[\ReturnTypeWillChange]   public function getChildren() {
    $filter = parent::getChildren();
    // Pass on the skipped folders list.     $filter->skippedFolders = $this->skippedFolders;
    // Pass the $acceptTests flag forward to child iterators.     $filter->acceptTests($this->acceptTests);
    return $filter;
  }

  /** * {@inheritdoc} */
  #[\ReturnTypeWillChange]   public function accept() {
    $name = $this->current()->getFilename();
    // FilesystemIterator::SKIP_DOTS only skips '.' and '..', but not hidden     // directories (like '.git').
// Allow directories specified in settings.php to be ignored. You can use     // this to not check for files in common special-purpose directories. For     // example, node_modules and bower_components. Ignoring irrelevant     // directories is a performance boost.     $ignore_directories = Settings::get('file_scan_ignore_directories', []);

    // Filter the recursive scan to discover extensions only.     // Important: Without a RecursiveFilterIterator, RecursiveDirectoryIterator     // would recurse into the entire filesystem directory tree without any kind     // of limitations.     $filter = new RecursiveExtensionFilterIterator($directory_iterator$ignore_directories);
    $filter->acceptTests($include_tests);

    // The actual recursive filesystem scan is only invoked by instantiating the     // RecursiveIteratorIterator.     $iterator = new \RecursiveIteratorIterator($filter,
      \RecursiveIteratorIterator::LEAVES_ONLY,
      // Suppress filesystem errors in case a directory cannot be accessed.       \RecursiveIteratorIterator::CATCH_GET_CHILD
    );

    foreach ($iterator as $key => $fileinfo) {
      // All extension names in Drupal have to be valid PHP function names due
Home | Imprint | This part of the site doesn't use cookies.