Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Finder.php

function Finder::in

Searches files and directories which match defined rules.

Parameters

string|string[] $dirs A directory path or an array of directories:

Return value

$this

Throws

DirectoryNotFoundException if one of the directories does not exist

File

vendor/symfony/finder/Finder.php, line 635

Class

Finder
Finder allows to build rules to find files and directories.

Namespace

Symfony\Component\Finder

Code

public function in(string|array $dirs) : static {
    $resolvedDirs = [];
    foreach ((array) $dirs as $dir) {
        if (is_dir($dir)) {
            $resolvedDirs[] = [
                $this->normalizeDir($dir),
            ];
        }
        elseif ($glob = glob($dir, (\defined('GLOB_BRACE') ? \GLOB_BRACE : 0) | \GLOB_ONLYDIR | \GLOB_NOSORT)) {
            sort($glob);
            $resolvedDirs[] = array_map($this->normalizeDir(...), $glob);
        }
        else {
            throw new DirectoryNotFoundException(\sprintf('The "%s" directory does not exist.', $dir));
        }
    }
    $this->dirs = array_merge($this->dirs, ...$resolvedDirs);
    return $this;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal