Symfony\Component\Finder\Finder
Finder allows to build rules to find files and directories.
It is a thin wrapper around several specialized iterator classes.
All rules may be invoked several times.
All methods return the current Finder object to allow easy chaining:
$finder = Finder::create()->files()->name('*.php')->in(__DIR__);
- Author: Fabien Potencier <fabien@symfony.com>
Synopsis
class Finder
implements
IteratorAggregate,Countable
{
- // constants
- const IGNORE_VCS_FILES = 1;
- const IGNORE_DOT_FILES = 2;
- // members
- private integer $mode;
- private array $names;
- private array $notNames;
- private array $exclude;
- private array $filters;
- private array $depths;
- private array $sizes;
- private $followLinks;
- private $sort;
- private integer $ignore;
- private array $dirs;
- private array $dates;
- private array $iterators;
- private array $contains;
- private array $notContains;
- private array $adapters;
- private array $paths;
- private array $notPaths;
- private $ignoreUnreadableDirs;
- private array $vcsPatterns;
- // methods
- public void __construct()
- public static Finder create()
- public Finder addAdapter()
- public Finder useBestAdapter()
- public Finder setAdapter()
- public Finder removeAdapters()
- public array getAdapters()
- public Finder directories()
- public Finder files()
- public Finder depth()
- public Finder date()
- public Finder name()
- public Finder notName()
- public Finder contains()
- public Finder notContains()
- public Finder path()
- public Finder notPath()
- public Finder size()
- public Finder exclude()
- public Finder ignoreDotFiles()
- public Finder ignoreVCS()
- public static void addVCSPattern()
- public Finder sort()
- public Finder sortByName()
- public Finder sortByType()
- public Finder sortByAccessedTime()
- public Finder sortByChangedTime()
- public Finder sortByModifiedTime()
- public Finder filter()
- public Finder followLinks()
- public Finder ignoreUnreadableDirs()
- public Finder in()
- public Iterator getIterator()
- public Finder append()
- public int count()
- private Finder sortAdapters()
- private Iterator searchInDirectory()
- private AdapterInterface buildAdapter()
- private void resetAdapterSelection()
Hierarchy
Implements
Constants
Name | Value |
---|---|
IGNORE_VCS_FILES | 1 |
IGNORE_DOT_FILES | 2 |
Members
private
- $adapters
- $contains
- $dates
- $depths
- $dirs
- $exclude
- $filters
- $followLinks
- $ignore
- $ignoreUnreadableDirs
- $iterators
- $mode
- $names
- $notContains
- $notNames
- $notPaths
- $paths
- $sizes
- $sort
- $vcsPatterns
Methods
private
- buildAdapter()
- resetAdapterSelection() — Unselects all adapters.
- searchInDirectory()
- sortAdapters()
public
- __construct() — Constructor.
- addAdapter() — Registers a finder engine implementation.
- addVCSPattern() — Adds VCS patterns.
- append() — Appends an existing set of files/directories to the finder.
- contains() — Adds tests that file contents must match.
- count() — Counts all the results collected by the iterators.
- create() — Creates a new Finder.
- date() — Adds tests for file dates (last modified).
- depth() — Adds tests for the directory depth.
- directories() — Restricts the matching to directories only.
- exclude() — Excludes directories.
- files() — Restricts the matching to files only.
- filter() — Filters the iterator with an anonymous function.
- followLinks() — Forces the following of symlinks.
- getAdapters() — Returns registered adapters ordered by priority without extra information.
- getIterator() — Returns an Iterator for the current Finder configuration.
- ignoreDotFiles() — Excludes "hidden" directories and files (starting with a dot).
- ignoreUnreadableDirs() — Tells finder to ignore unreadable directories.
- ignoreVCS() — Forces the finder to ignore version control directories.
- in() — Searches files and directories which match defined rules.
- name() — Adds rules that files must match.
- notContains() — Adds tests that file contents must not match.
- notName() — Adds rules that files must not match.
- notPath() — Adds rules that filenames must not match.
- path() — Adds rules that filenames must match.
- removeAdapters() — Removes all adapters registered in the finder.
- setAdapter() — Selects the adapter to use.
- size() — Adds tests for file sizes.
- sort() — Sorts files and directories by an anonymous function.
- sortByAccessedTime() — Sorts files and directories by the last accessed time.
- sortByChangedTime() — Sorts files and directories by the last inode changed time.
- sortByModifiedTime() — Sorts files and directories by the last modified time.
- sortByName() — Sorts files and directories by name.
- sortByType() — Sorts files and directories by type (directories before files), then by name.
- useBestAdapter() — Sets the selected adapter to the best one according to the current platform the code is run on.