PHP 클래스 Symfony\Component\Finder\Finder

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__);
저자: Fabien Potencier ([email protected])
상속: implements IteratorAggregate, implements Countable
파일 보기 프로젝트 열기: symfony/symfony 1 사용 예제들

공개 메소드들

메소드 설명
__construct ( ) Constructor.
addVCSPattern ( string | string[] $pattern ) Adds VCS patterns.
append ( mixed $iterator ) : Finder | Symfony\Component\Finder\SplFileInfo[] Appends an existing set of files/directories to the finder.
contains ( string $pattern ) : Finder | Symfony\Component\Finder\SplFileInfo[] Adds tests that file contents must match.
count ( ) : integer Counts all the results collected by the iterators.
create ( ) : Finder Creates a new Finder.
date ( string $date ) : Finder | Symfony\Component\Finder\SplFileInfo[] Adds tests for file dates (last modified).
depth ( string | integer $level ) : Finder | Symfony\Component\Finder\SplFileInfo[] Adds tests for the directory depth.
directories ( ) : Finder | Symfony\Component\Finder\SplFileInfo[] Restricts the matching to directories only.
exclude ( string | array $dirs ) : Finder | Symfony\Component\Finder\SplFileInfo[] Excludes directories.
files ( ) : Finder | Symfony\Component\Finder\SplFileInfo[] Restricts the matching to files only.
filter ( Closure $closure ) : Finder | Symfony\Component\Finder\SplFileInfo[] Filters the iterator with an anonymous function.
followLinks ( ) : Finder | Symfony\Component\Finder\SplFileInfo[] Forces the following of symlinks.
getIterator ( ) : Iterator | Symfony\Component\Finder\SplFileInfo[] Returns an Iterator for the current Finder configuration.
ignoreDotFiles ( boolean $ignoreDotFiles ) : Finder | Symfony\Component\Finder\SplFileInfo[] Excludes "hidden" directories and files (starting with a dot).
ignoreUnreadableDirs ( boolean $ignore = true ) : Finder | Symfony\Component\Finder\SplFileInfo[] Tells finder to ignore unreadable directories.
ignoreVCS ( boolean $ignoreVCS ) : Finder | Symfony\Component\Finder\SplFileInfo[] Forces the finder to ignore version control directories.
in ( string | array $dirs ) : Finder | Symfony\Component\Finder\SplFileInfo[] Searches files and directories which match defined rules.
name ( string $pattern ) : Finder | Symfony\Component\Finder\SplFileInfo[] Adds rules that files must match.
notContains ( string $pattern ) : Finder | Symfony\Component\Finder\SplFileInfo[] Adds tests that file contents must not match.
notName ( string $pattern ) : Finder | Symfony\Component\Finder\SplFileInfo[] Adds rules that files must not match.
notPath ( string $pattern ) : Finder | Symfony\Component\Finder\SplFileInfo[] Adds rules that filenames must not match.
path ( string $pattern ) : Finder | Symfony\Component\Finder\SplFileInfo[] Adds rules that filenames must match.
size ( string | integer $size ) : Finder | Symfony\Component\Finder\SplFileInfo[] Adds tests for file sizes.
sort ( Closure $closure ) : Finder | Symfony\Component\Finder\SplFileInfo[] Sorts files and directories by an anonymous function.
sortByAccessedTime ( ) : Finder | Symfony\Component\Finder\SplFileInfo[] Sorts files and directories by the last accessed time.
sortByChangedTime ( ) : Finder | Symfony\Component\Finder\SplFileInfo[] Sorts files and directories by the last inode changed time.
sortByModifiedTime ( ) : Finder | Symfony\Component\Finder\SplFileInfo[] Sorts files and directories by the last modified time.
sortByName ( ) : Finder | Symfony\Component\Finder\SplFileInfo[] Sorts files and directories by name.
sortByType ( ) : Finder | Symfony\Component\Finder\SplFileInfo[] Sorts files and directories by type (directories before files), then by name.

비공개 메소드들

메소드 설명
searchInDirectory ( $dir ) : Iterator

메소드 상세

__construct() 공개 메소드

Constructor.
public __construct ( )

addVCSPattern() 공개 정적인 메소드

Adds VCS patterns.
또한 보기: ignoreVCS()
public static addVCSPattern ( string | string[] $pattern )
$pattern string | string[] VCS patterns to ignore

append() 공개 메소드

The set can be another Finder, an Iterator, an IteratorAggregate, or even a plain array.
public append ( mixed $iterator ) : Finder | Symfony\Component\Finder\SplFileInfo[]
$iterator mixed
리턴 Finder | Symfony\Component\Finder\SplFileInfo[] The finder

contains() 공개 메소드

Strings or PCRE patterns can be used: $finder->contains('Lorem ipsum') $finder->contains('/Lorem ipsum/i')
또한 보기: FilecontentFilterIterator
public contains ( string $pattern ) : Finder | Symfony\Component\Finder\SplFileInfo[]
$pattern string A pattern (string or regexp)
리턴 Finder | Symfony\Component\Finder\SplFileInfo[] The current Finder instance

count() 공개 메소드

Counts all the results collected by the iterators.
public count ( ) : integer
리턴 integer

create() 공개 정적인 메소드

Creates a new Finder.
public static create ( ) : Finder
리턴 Finder A new Finder instance

date() 공개 메소드

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');
또한 보기: strtotime
또한 보기: DateRangeFilterIterator
또한 보기: DateComparator
public date ( string $date ) : Finder | Symfony\Component\Finder\SplFileInfo[]
$date string A date range string
리턴 Finder | Symfony\Component\Finder\SplFileInfo[] The current Finder instance

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.
또한 보기: DepthRangeFilterIterator
또한 보기: NumberComparator
public depth ( string | integer $level ) : Finder | Symfony\Component\Finder\SplFileInfo[]
$level string | integer The depth level expression
리턴 Finder | Symfony\Component\Finder\SplFileInfo[] The current Finder instance

directories() 공개 메소드

Restricts the matching to directories only.
public directories ( ) : Finder | Symfony\Component\Finder\SplFileInfo[]
리턴 Finder | Symfony\Component\Finder\SplFileInfo[] The current Finder instance

exclude() 공개 메소드

Excludes directories.
또한 보기: ExcludeDirectoryFilterIterator
public exclude ( string | array $dirs ) : Finder | Symfony\Component\Finder\SplFileInfo[]
$dirs string | array A directory path or an array of directories
리턴 Finder | Symfony\Component\Finder\SplFileInfo[] The current Finder instance

files() 공개 메소드

Restricts the matching to files only.
public files ( ) : Finder | Symfony\Component\Finder\SplFileInfo[]
리턴 Finder | Symfony\Component\Finder\SplFileInfo[] The current Finder instance

filter() 공개 메소드

The anonymous function receives a \SplFileInfo and must return false to remove files.
또한 보기: CustomFilterIterator
public filter ( Closure $closure ) : Finder | Symfony\Component\Finder\SplFileInfo[]
$closure Closure An anonymous function
리턴 Finder | Symfony\Component\Finder\SplFileInfo[] The current Finder instance

getIterator() 공개 메소드

This method implements the IteratorAggregate interface.
public getIterator ( ) : Iterator | Symfony\Component\Finder\SplFileInfo[]
리턴 Iterator | Symfony\Component\Finder\SplFileInfo[] An iterator

ignoreDotFiles() 공개 메소드

Excludes "hidden" directories and files (starting with a dot).
또한 보기: ExcludeDirectoryFilterIterator
public ignoreDotFiles ( boolean $ignoreDotFiles ) : Finder | Symfony\Component\Finder\SplFileInfo[]
$ignoreDotFiles boolean Whether to exclude "hidden" files or not
리턴 Finder | Symfony\Component\Finder\SplFileInfo[] The current Finder instance

ignoreUnreadableDirs() 공개 메소드

By default, scanning unreadable directories content throws an AccessDeniedException.
public ignoreUnreadableDirs ( boolean $ignore = true ) : Finder | Symfony\Component\Finder\SplFileInfo[]
$ignore boolean
리턴 Finder | Symfony\Component\Finder\SplFileInfo[] The current Finder instance

ignoreVCS() 공개 메소드

Forces the finder to ignore version control directories.
또한 보기: ExcludeDirectoryFilterIterator
public ignoreVCS ( boolean $ignoreVCS ) : Finder | Symfony\Component\Finder\SplFileInfo[]
$ignoreVCS boolean Whether to exclude VCS files or not
리턴 Finder | Symfony\Component\Finder\SplFileInfo[] The current Finder instance

in() 공개 메소드

Searches files and directories which match defined rules.
public in ( string | array $dirs ) : Finder | Symfony\Component\Finder\SplFileInfo[]
$dirs string | array A directory path or an array of directories
리턴 Finder | Symfony\Component\Finder\SplFileInfo[] The current Finder instance

name() 공개 메소드

You can use patterns (delimited with / sign), globs or simple strings. $finder->name('*.php') $finder->name('/\.php$/') // same as above $finder->name('test.php')
또한 보기: FilenameFilterIterator
public name ( string $pattern ) : Finder | Symfony\Component\Finder\SplFileInfo[]
$pattern string A pattern (a regexp, a glob, or a string)
리턴 Finder | Symfony\Component\Finder\SplFileInfo[] The current Finder instance

notContains() 공개 메소드

Strings or PCRE patterns can be used: $finder->notContains('Lorem ipsum') $finder->notContains('/Lorem ipsum/i')
또한 보기: FilecontentFilterIterator
public notContains ( string $pattern ) : Finder | Symfony\Component\Finder\SplFileInfo[]
$pattern string A pattern (string or regexp)
리턴 Finder | Symfony\Component\Finder\SplFileInfo[] The current Finder instance

notName() 공개 메소드

Adds rules that files must not match.
또한 보기: FilenameFilterIterator
public notName ( string $pattern ) : Finder | Symfony\Component\Finder\SplFileInfo[]
$pattern string A pattern (a regexp, a glob, or a string)
리턴 Finder | Symfony\Component\Finder\SplFileInfo[] The current Finder instance

notPath() 공개 메소드

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.
또한 보기: FilenameFilterIterator
public notPath ( string $pattern ) : Finder | Symfony\Component\Finder\SplFileInfo[]
$pattern string A pattern (a regexp or a string)
리턴 Finder | Symfony\Component\Finder\SplFileInfo[] The current Finder instance

path() 공개 메소드

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.
또한 보기: FilenameFilterIterator
public path ( string $pattern ) : Finder | Symfony\Component\Finder\SplFileInfo[]
$pattern string A pattern (a regexp or a string)
리턴 Finder | Symfony\Component\Finder\SplFileInfo[] The current Finder instance

size() 공개 메소드

$finder->size('> 10K'); $finder->size('<= 1Ki'); $finder->size(4);
또한 보기: SizeRangeFilterIterator
또한 보기: NumberComparator
public size ( string | integer $size ) : Finder | Symfony\Component\Finder\SplFileInfo[]
$size string | integer A size range string or an integer
리턴 Finder | Symfony\Component\Finder\SplFileInfo[] The current Finder instance

sort() 공개 메소드

The anonymous function receives two \SplFileInfo instances to compare. This can be slow as all the matching files and directories must be retrieved for comparison.
또한 보기: SortableIterator
public sort ( Closure $closure ) : Finder | Symfony\Component\Finder\SplFileInfo[]
$closure Closure An anonymous function
리턴 Finder | Symfony\Component\Finder\SplFileInfo[] The current Finder instance

sortByAccessedTime() 공개 메소드

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.
또한 보기: SortableIterator
public sortByAccessedTime ( ) : Finder | Symfony\Component\Finder\SplFileInfo[]
리턴 Finder | Symfony\Component\Finder\SplFileInfo[] The current Finder instance

sortByChangedTime() 공개 메소드

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.
또한 보기: SortableIterator
public sortByChangedTime ( ) : Finder | Symfony\Component\Finder\SplFileInfo[]
리턴 Finder | Symfony\Component\Finder\SplFileInfo[] The current Finder instance

sortByModifiedTime() 공개 메소드

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.
또한 보기: SortableIterator
public sortByModifiedTime ( ) : Finder | Symfony\Component\Finder\SplFileInfo[]
리턴 Finder | Symfony\Component\Finder\SplFileInfo[] The current Finder instance

sortByName() 공개 메소드

This can be slow as all the matching files and directories must be retrieved for comparison.
또한 보기: SortableIterator
public sortByName ( ) : Finder | Symfony\Component\Finder\SplFileInfo[]
리턴 Finder | Symfony\Component\Finder\SplFileInfo[] The current Finder instance

sortByType() 공개 메소드

This can be slow as all the matching files and directories must be retrieved for comparison.
또한 보기: SortableIterator
public sortByType ( ) : Finder | Symfony\Component\Finder\SplFileInfo[]
리턴 Finder | Symfony\Component\Finder\SplFileInfo[] The current Finder instance