Symfony\Component\Finder\Finder::path PHP Method

path() public method

You can use patterns (delimited with / sign) or simple strings. $finder->path('some/special/dir') $finder->path('/some\/special\/dir/') // same as above Use only / as dirname separator.
See also: FilenameFilterIterator
public path ( string $pattern ) : Finder | Symfony\Component\Finder\SplFileInfo[]
$pattern string A pattern (a regexp or a string)
return Finder | Symfony\Component\Finder\SplFileInfo[] The current Finder instance
    public function path($pattern)
    {
        $this->paths[] = $pattern;

        return $this;
    }

Usage Example

Example #1
0
 /**
  * Create a map for a given path
  *
  * @param array $paths
  * @return array
  */
 public function createMap(...$paths)
 {
     $classes = [];
     $this->finder->files()->ignoreUnreadableDirs()->in($paths);
     foreach ($this->excludePathPatterns as $exclude) {
         $this->finder->notPath($exclude);
     }
     foreach ($this->inPathPatterns as $inPath) {
         $this->finder->path($inPath);
     }
     foreach ($this->names as $name) {
         $this->finder->name($name);
     }
     /** @var SplFileInfo $file */
     foreach ($this->finder as $file) {
         $content = file_get_contents($file->getPathname());
         preg_match('^\\s*class ([\\S]*)\\s*(extends|implements|{)^', $content, $match, PREG_OFFSET_CAPTURE);
         if (isset($match[1])) {
             $className = '\\' . trim($match[1][0]);
             $offset = $match[1][1];
         } else {
             continue;
         }
         preg_match('|\\s*namespace\\s*([\\S]*)\\s*;|', substr($content, 0, $offset), $match);
         if (isset($match[1]) && trim($match[1]) !== '') {
             $className = '\\' . trim($match[1]) . $className;
         }
         if ($className !== '\\') {
             $classes[$file->getPathname()] = $className;
         }
     }
     return $classes;
 }
All Usage Examples Of Symfony\Component\Finder\Finder::path