TYPO3
7.6
|
Public Member Functions | |
__construct () | |
addAdapter (AdapterInterface $adapter, $priority=0) | |
useBestAdapter () | |
setAdapter ($name) | |
removeAdapters () | |
getAdapters () | |
directories () | |
files () | |
depth ($level) | |
date ($date) | |
name ($pattern) | |
notName ($pattern) | |
contains ($pattern) | |
notContains ($pattern) | |
path ($pattern) | |
notPath ($pattern) | |
size ($size) | |
exclude ($dirs) | |
ignoreDotFiles ($ignoreDotFiles) | |
ignoreVCS ($ignoreVCS) | |
sort (\Closure $closure) | |
sortByName () | |
sortByType () | |
sortByAccessedTime () | |
sortByChangedTime () | |
sortByModifiedTime () | |
filter (\Closure $closure) | |
followLinks () | |
ignoreUnreadableDirs ($ignore=true) | |
in ($dirs) | |
getIterator () | |
append ($iterator) | |
count () | |
Static Public Member Functions | |
static | create () |
static | addVCSPattern ($pattern) |
Public Attributes | |
const | IGNORE_VCS_FILES = 1 |
const | IGNORE_DOT_FILES = 2 |
Private Member Functions | |
sortAdapters () | |
searchInDirectory ($dir) | |
buildAdapter (AdapterInterface $adapter) | |
resetAdapterSelection () | |
Private Attributes | |
$mode = 0 | |
$names = array() | |
$notNames = array() | |
$exclude = array() | |
$filters = array() | |
$depths = array() | |
$sizes = array() | |
$followLinks = false | |
$sort = false | |
$ignore = 0 | |
$dirs = array() | |
$dates = array() | |
$iterators = array() | |
$contains = array() | |
$notContains = array() | |
$adapters = array() | |
$paths = array() | |
$notPaths = array() | |
$ignoreUnreadableDirs = false | |
Static Private Attributes | |
static | $vcsPatterns = array('.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg') |
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);
Definition at line 45 of file Finder.php.
__construct | ( | ) |
Constructor.
Definition at line 75 of file Finder.php.
addAdapter | ( | AdapterInterface | $adapter, |
$priority = 0 |
|||
) |
Registers a finder engine implementation.
AdapterInterface | $adapter | An adapter instance |
int | $priority | Highest is selected first |
Definition at line 107 of file Finder.php.
References AdapterInterface\getName(), and Finder\sortAdapters().
|
static |
Adds VCS patterns.
string|string[] | $pattern VCS patterns to ignore |
Definition at line 476 of file Finder.php.
append | ( | $iterator | ) |
Appends an existing set of files/directories to the finder.
The set can be another Finder, an Iterator, an IteratorAggregate, or even a plain array.
mixed | $iterator |
\InvalidArgumentException | When the given argument is not iterable. |
Definition at line 728 of file Finder.php.
References elseif.
|
private |
AdapterInterface | $adapter |
Definition at line 809 of file Finder.php.
References Finder\contains(), Finder\exclude(), Finder\followLinks(), Finder\ignoreUnreadableDirs(), Finder\notContains(), AdapterInterface\setFollowLinks(), and Finder\sort().
contains | ( | $pattern | ) |
Adds tests that file contents must match.
Strings or PCRE patterns can be used:
$finder->contains('Lorem ipsum') $finder->contains('/Lorem ipsum/i')
string | $pattern | A pattern (string or regexp) |
Definition at line 310 of file Finder.php.
Referenced by Finder\buildAdapter().
count | ( | ) |
Counts all the results collected by the iterators.
Definition at line 752 of file Finder.php.
References Finder\getIterator().
Referenced by Finder\getIterator().
|
static |
Creates a new Finder.
Definition at line 94 of file Finder.php.
Referenced by FinderTest\buildFinder(), ClassMapGenerator\createMap(), FinderTest\testAdaptersChaining(), FinderTest\testAdapterSelection(), FinderTest\testAdaptersOrdering(), FinderTest\testAppendDoesNotRequireIn(), FinderTest\testCountDirectories(), FinderTest\testCountFiles(), FinderTest\testCountWithoutIn(), and FinderTest\testCreate().
date | ( | $date | ) |
Adds tests for file dates (last modified).
The date must be something that strtotime() is able to parse:
$finder->date('since yesterday'); $finder->date('until 2 days ago'); $finder->date('> now - 2 hours'); $finder->date('>= 2005-10-15');
string | $date | A date range string |
Definition at line 247 of file Finder.php.
depth | ( | $level | ) |
Adds tests for the directory depth.
Usage:
$finder->depth('> 1') // the Finder will start matching at level 1. $finder->depth('< 3') // the Finder will descend at most 3 levels of directories below the starting point.
int | $level | The depth level expression |
Definition at line 220 of file Finder.php.
directories | ( | ) |
Restricts the matching to directories only.
Definition at line 182 of file Finder.php.
exclude | ( | $dirs | ) |
Excludes directories.
string | array | $dirs | A directory path or an array of directories |
Definition at line 418 of file Finder.php.
References Finder\$dirs.
Referenced by Finder\buildAdapter(), and Finder\searchInDirectory().
files | ( | ) |
Restricts the matching to files only.
Definition at line 196 of file Finder.php.
filter | ( | \Closure | $closure | ) |
Filters the iterator with an anonymous function.
The anonymous function receives a and must return false to remove files.
\Closure | $closure | An anonymous function |
Definition at line 619 of file Finder.php.
followLinks | ( | ) |
Forces the following of symlinks.
Definition at line 633 of file Finder.php.
Referenced by Finder\buildAdapter().
getAdapters | ( | ) |
Returns registered adapters ordered by priority without extra information.
Definition at line 168 of file Finder.php.
References Finder\$adapters.
getIterator | ( | ) |
Returns an Iterator for the current Finder configuration.
This method implements the IteratorAggregate interface.
\LogicException | if the in() method has not been called |
Definition at line 695 of file Finder.php.
References Finder\count(), and Finder\searchInDirectory().
Referenced by Finder\count().
ignoreDotFiles | ( | $ignoreDotFiles | ) |
Excludes "hidden" directories and files (starting with a dot).
bool | $ignoreDotFiles | Whether to exclude "hidden" files or not |
Definition at line 436 of file Finder.php.
References Finder\IGNORE_DOT_FILES.
ignoreUnreadableDirs | ( | $ignore = true | ) |
Tells finder to ignore unreadable directories.
By default, scanning unreadable directories content throws an AccessDeniedException.
bool | $ignore |
Definition at line 649 of file Finder.php.
References Finder\$ignore.
Referenced by Finder\buildAdapter().
ignoreVCS | ( | $ignoreVCS | ) |
Forces the finder to ignore version control directories.
bool | $ignoreVCS | Whether to exclude VCS files or not |
Definition at line 458 of file Finder.php.
References Finder\IGNORE_VCS_FILES.
in | ( | $dirs | ) |
Searches files and directories which match defined rules.
string | array | $dirs | A directory path or an array of directories |
\InvalidArgumentException | if one of the directories does not exist |
Definition at line 667 of file Finder.php.
References Finder\$dirs, and elseif.
name | ( | $pattern | ) |
Adds rules that files must match.
You can use patterns (delimited with / sign), globs or simple strings.
$finder->name('*.php') $finder->name('/.php$/') // same as above $finder->name('test.php')
string | $pattern | A pattern (a regexp, a glob, or a string) |
Definition at line 271 of file Finder.php.
notContains | ( | $pattern | ) |
Adds tests that file contents must not match.
Strings or PCRE patterns can be used:
$finder->notContains('Lorem ipsum') $finder->notContains('/Lorem ipsum/i')
string | $pattern | A pattern (string or regexp) |
Definition at line 331 of file Finder.php.
Referenced by Finder\buildAdapter().
notName | ( | $pattern | ) |
Adds rules that files must not match.
string | $pattern | A pattern (a regexp, a glob, or a string) |
Definition at line 289 of file Finder.php.
notPath | ( | $pattern | ) |
Adds rules that filenames must not match.
You can use patterns (delimited with / sign) or simple strings.
$finder->notPath('some/special/dir') $finder->notPath('/some\/special\/dir/') // same as above
Use only / as dirname separator.
string | $pattern | A pattern (a regexp or a string) |
Definition at line 377 of file Finder.php.
path | ( | $pattern | ) |
Adds rules that filenames must match.
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.
string | $pattern | A pattern (a regexp or a string) |
Definition at line 354 of file Finder.php.
removeAdapters | ( | ) |
Removes all adapters registered in the finder.
Definition at line 156 of file Finder.php.
|
private |
Unselects all adapters.
Definition at line 832 of file Finder.php.
References Finder\$adapters.
Referenced by Finder\setAdapter(), and Finder\useBestAdapter().
|
private |
$dir |
\RuntimeException | When none of the adapters are supported |
Definition at line 780 of file Finder.php.
References Finder\exclude().
Referenced by Finder\getIterator().
setAdapter | ( | $name | ) |
Selects the adapter to use.
string | $name |
\InvalidArgumentException |
Definition at line 139 of file Finder.php.
References Finder\resetAdapterSelection(), and Finder\sortAdapters().
size | ( | $size | ) |
Adds tests for file sizes.
$finder->size('> 10K'); $finder->size('<= 1Ki'); $finder->size(4);
string | $size | A size range string |
Definition at line 400 of file Finder.php.
sort | ( | \Closure | $closure | ) |
Sorts files and directories by an anonymous function.
The anonymous function receives two instances to compare.
This can be slow as all the matching files and directories must be retrieved for comparison.
\Closure | $closure | An anonymous function |
Definition at line 500 of file Finder.php.
Referenced by Finder\buildAdapter(), Finder\sortByAccessedTime(), Finder\sortByChangedTime(), Finder\sortByModifiedTime(), Finder\sortByName(), and Finder\sortByType().
|
private |
Definition at line 760 of file Finder.php.
Referenced by Finder\addAdapter(), Finder\setAdapter(), and Finder\useBestAdapter().
sortByAccessedTime | ( | ) |
Sorts files and directories by the last accessed time.
This is the time that the file was last accessed, read or written to.
This can be slow as all the matching files and directories must be retrieved for comparison.
Definition at line 556 of file Finder.php.
References Finder\sort().
sortByChangedTime | ( | ) |
Sorts files and directories by the last inode changed time.
This is the time that the inode information was last modified (permissions, owner, group or other metadata).
On Windows, since inode is not available, changed time is actually the file creation time.
This can be slow as all the matching files and directories must be retrieved for comparison.
Definition at line 578 of file Finder.php.
References Finder\sort().
sortByModifiedTime | ( | ) |
Sorts files and directories by the last modified time.
This is the last time the actual contents of the file were last modified.
This can be slow as all the matching files and directories must be retrieved for comparison.
Definition at line 598 of file Finder.php.
References Finder\sort().
sortByName | ( | ) |
Sorts files and directories by name.
This can be slow as all the matching files and directories must be retrieved for comparison.
Definition at line 518 of file Finder.php.
References Finder\sort().
sortByType | ( | ) |
Sorts files and directories by type (directories before files), then by name.
This can be slow as all the matching files and directories must be retrieved for comparison.
Definition at line 536 of file Finder.php.
References Finder\sort().
useBestAdapter | ( | ) |
Sets the selected adapter to the best one according to the current platform the code is run on.
Definition at line 123 of file Finder.php.
References Finder\resetAdapterSelection(), and Finder\sortAdapters().
|
private |
Definition at line 65 of file Finder.php.
Referenced by Finder\getAdapters(), and Finder\resetAdapterSelection().
|
private |
Definition at line 63 of file Finder.php.
|
private |
Definition at line 61 of file Finder.php.
|
private |
Definition at line 55 of file Finder.php.
|
private |
Definition at line 60 of file Finder.php.
Referenced by Finder\exclude(), and Finder\in().
|
private |
Definition at line 53 of file Finder.php.
|
private |
Definition at line 54 of file Finder.php.
|
private |
Definition at line 57 of file Finder.php.
|
private |
Definition at line 59 of file Finder.php.
Referenced by Finder\ignoreUnreadableDirs().
|
private |
Definition at line 68 of file Finder.php.
|
private |
Definition at line 62 of file Finder.php.
|
private |
Definition at line 50 of file Finder.php.
|
private |
Definition at line 51 of file Finder.php.
|
private |
Definition at line 64 of file Finder.php.
|
private |
Definition at line 52 of file Finder.php.
|
private |
Definition at line 67 of file Finder.php.
|
private |
Definition at line 66 of file Finder.php.
|
private |
Definition at line 56 of file Finder.php.
|
private |
Definition at line 58 of file Finder.php.
|
staticprivate |
Definition at line 70 of file Finder.php.
const IGNORE_DOT_FILES = 2 |
Definition at line 48 of file Finder.php.
Referenced by Finder\ignoreDotFiles().
const IGNORE_VCS_FILES = 1 |
Definition at line 47 of file Finder.php.
Referenced by Finder\ignoreVCS().