function Finder::__construct

Same name in this branch
  1. main core/lib/Drupal/Core/DefaultContent/Finder.php \Drupal\Core\DefaultContent\Finder::__construct()
Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/DefaultContent/Finder.php \Drupal\Core\DefaultContent\Finder::__construct()
  2. 10 core/lib/Drupal/Core/DefaultContent/Finder.php \Drupal\Core\DefaultContent\Finder::__construct()

Constructs a recipe finder.

Parameters

string|array|null $directories: (optional) The directories that should be searched for recipes, or NULL to use the default locations.

bool $skipInvalid: (optional) Whether to silently skip invalid recipes, or allow them to throw exceptions.

\Psr\Log\LoggerInterface|null $logger: (optional) A logger where exceptions raised by invalid recipes should be logged.

File

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

Class

Finder
Discovers recipes at specific locations in the file system.

Namespace

Drupal\Core\Recipe

Code

public function __construct(string|array|null $directories = NULL, private readonly bool $skipInvalid = FALSE, public readonly ?LoggerInterface $logger = NULL) {
  parent::__construct();
  $directories ??= [
    // Placeholders used by the Composer installer don't make sense here.
    // For example, if Composer is configured to install recipes in
    // `./recipes/{$name}`, we really just want to scan `./recipes`.
str_replace([
      '{$vendor}',
      '{$name}',
    ], '', self::getComposerRecipesDirectory()),
    // Drupal runs in the web root, so this directory is guaranteed to exist
    // (and Finder will throw if it doesn't).
'core/recipes',
  ];
  $this->in($directories)
    ->followLinks();
}

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