function Finder::getIterator

File

core/lib/Drupal/Core/Recipe/Finder.php, line 79

Class

Finder
Discovers recipes at specific locations in the file system.

Namespace

Drupal\Core\Recipe

Code

public function getIterator() : \Generator {
  // Set options that should never be configurable by calling code, so that
  // we can guarantee they are what we expect them to be before iterating.
  // Calling name() and depth() on $this is forbidden, so we need to set those
  // options on the parent class.
  $this->files();
  parent::name('recipe.yml');
  parent::depth(1);
  foreach (parent::getIterator() as $file) {
    try {
      yield Recipe::createFromDirectory($file->getPath());
    } catch (\Throwable $e) {
      $this->logger?->error($e->getMessage());
      if ($this->skipInvalid) {
        continue;
      }
      throw $e;
    }
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.