本文整理匯總了PHP中Symfony\Component\Finder\Finder::size方法的典型用法代碼示例。如果您正苦於以下問題:PHP Finder::size方法的具體用法?PHP Finder::size怎麽用?PHP Finder::size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\Finder\Finder
的用法示例。
在下文中一共展示了Finder::size方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: withFilters
/**
* @param array $filters
* @return $this
*/
public function withFilters(array $filters)
{
if (!empty($filters)) {
foreach ($filters as $currentFilter) {
if (!strpos($currentFilter, ':')) {
throw new \InvalidArgumentException(sprintf('The filter "%s" is not a valid filter. A valid filter has the format <name>:<value>.', $currentFilter));
}
$currentFilterElements = explode(':', $currentFilter, 2);
switch (trim($currentFilterElements[0])) {
case 'exclude':
$this->finder->exclude($currentFilterElements[1]);
break;
case 'name':
$this->finder->name($currentFilterElements[1]);
break;
case 'notName':
$this->finder->notName($currentFilterElements[1]);
break;
case 'path':
$this->finder->path($currentFilterElements[1]);
break;
case 'size':
$this->finder->size($currentFilterElements[1]);
}
}
}
return $this;
}
示例2: index
public function index()
{
/*
|--------------------------------------------------------------------------
| Paramers
|--------------------------------------------------------------------------
|
| Match overrides Extension. Exclusion applies in both cases.
|
*/
$match = $this->fetchParam('match', false);
$exclude = $this->fetchParam('exclude', false);
$extension = $this->fetchParam('extension', false);
$in = $this->fetchParam('in', false);
$not_in = $this->fetchParam('not_in', false);
$file_size = $this->fetchParam('file_size', false);
$file_date = $this->fetchParam('file_date', false);
$depth = $this->fetchParam('depth', false);
if ($file_size) {
$file_size = Helper::explodeOptions($file_size);
}
if ($extension) {
$extension = Helper::explodeOptions($extension);
}
/*
|--------------------------------------------------------------------------
| Finder
|--------------------------------------------------------------------------
|
| Get_Files implements most of the Symfony Finder component as a clean
| tag wrapper mapped to matched filenames.
|
*/
$finder = new Finder();
$finder->in($in);
// Finder doesn't respect multiple glob options,
// so this will need to wait until later.
//
// $match = str_replace('{{', '{', $match);
// $match = str_replace('}}', '}', $match);
/*
|--------------------------------------------------------------------------
| Name
|--------------------------------------------------------------------------
|
| Match is the "native" Finder name() method, which is supposed to
| implement string, glob, and regex. The glob support is only partial,
| so "extension" is a looped *single* glob rule iterator.
|
*/
if ($match) {
$finder->name($match);
} elseif ($extension) {
foreach ($extension as $ext) {
$finder->name("*.{$ext}");
}
}
/*
|--------------------------------------------------------------------------
| Exclude
|--------------------------------------------------------------------------
|
| Exclude directories from matching. Remapped to "not in" to allow more
| intuitive differentiation between filename and directory matching.
|
*/
if ($not_in) {
$finder->exclude($not_in);
}
/*
|--------------------------------------------------------------------------
| Not Name
|--------------------------------------------------------------------------
|
| Exclude files matching a given pattern: string, regex, or glob.
|
*/
if ($exclude) {
$finder->notName($exclude);
}
/*
|--------------------------------------------------------------------------
| File Size
|--------------------------------------------------------------------------
|
| Restrict files by size. Can be chained and allows comparison operators.
|
*/
if ($file_size) {
foreach ($file_size as $size) {
$finder->size($size);
}
}
/*
|--------------------------------------------------------------------------
| File Date
|--------------------------------------------------------------------------
|
| Restrict files by last modified date. Can use comparison operators, and
| since/after is aliased to >, and until/before to <.
//.........這裏部分代碼省略.........
示例3: index
public function index()
{
/*
|--------------------------------------------------------------------------
| Paramers
|--------------------------------------------------------------------------
|
| Match overrides Extension. Exclusion applies in both cases.
|
*/
$match = $this->fetchParam('match', false);
$exclude = $this->fetchParam('exclude', false);
$extension = $this->fetchParam(array('extension', 'type'), false);
$in = $this->fetchParam(array('in', 'folder', 'from'), false);
$not_in = $this->fetchParam('not_in', false);
$file_size = $this->fetchParam('file_size', false);
$file_date = $this->fetchParam('file_date', false);
$depth = $this->fetchParam('depth', false);
$sort_by = $this->fetchParam(array('sort_by', 'order_by'), false);
$sort_dir = $this->fetchParam(array('sort_dir', 'sort_direction'), 'asc');
$limit = $this->fetchParam('limit', false);
if ($in) {
$in = Helper::explodeOptions($in);
}
if ($not_in) {
$not_in = Helper::explodeOptions($not_in);
}
if ($file_size) {
$file_size = Helper::explodeOptions($file_size);
}
if ($extension) {
$extension = Helper::explodeOptions($extension);
}
/*
|--------------------------------------------------------------------------
| Finder
|--------------------------------------------------------------------------
|
| Get_Files implements most of the Symfony Finder component as a clean
| tag wrapper mapped to matched filenames.
|
*/
$finder = new Finder();
if ($in) {
foreach ($in as $location) {
$finder->in(Path::fromAsset($location));
}
}
/*
|--------------------------------------------------------------------------
| Name
|--------------------------------------------------------------------------
|
| Match is the "native" Finder name() method, which is supposed to
| implement string, glob, and regex. The glob support is only partial,
| so "extension" is a looped *single* glob rule iterator.
|
*/
if ($match) {
$finder->name($match);
} elseif ($extension) {
foreach ($extension as $ext) {
$finder->name("*.{$ext}");
}
}
/*
|--------------------------------------------------------------------------
| Exclude
|--------------------------------------------------------------------------
|
| Exclude directories from matching. Remapped to "not in" to allow more
| intuitive differentiation between filename and directory matching.
|
*/
if ($not_in) {
foreach ($not_in as $location) {
$finder->exclude($location);
}
}
/*
|--------------------------------------------------------------------------
| Not Name
|--------------------------------------------------------------------------
|
| Exclude files matching a given pattern: string, regex, or glob.
| By default we don't allow looking for PHP files. Be smart.
|
*/
if ($this->fetchParam('allow_php', false) !== TRUE) {
$finder->notName("*.php");
}
if ($exclude) {
$finder->notName($exclude);
}
/*
|--------------------------------------------------------------------------
| File Size
|--------------------------------------------------------------------------
|
| Restrict files by size. Can be chained and allows comparison operators.
//.........這裏部分代碼省略.........
示例4: createFinder
/**
* @param InputInterface $input
* @return Finder
*/
public function createFinder(InputInterface $input)
{
$finder = new Finder();
$finder->files();
foreach ($input->getArgument('directory') as $dir) {
$finder->in($dir);
}
foreach ($input->getOption('not-dir') as $ignoreDir) {
$finder->exclude($ignoreDir);
}
foreach ($input->getOption('file-name') as $pattern) {
$finder->name($pattern);
}
foreach ($input->getOption('not-file-name') as $pattern) {
$finder->notName($pattern);
}
foreach ($input->getOption('contains') as $pattern) {
$finder->contains($pattern);
}
foreach ($input->getOption('not-contains') as $pattern) {
$finder->notContains($pattern);
}
foreach ($input->getOption('path') as $pattern) {
$finder->path($pattern);
}
foreach ($input->getOption('not-path') as $pattern) {
$finder->notPath($pattern);
}
if ($size = $input->getOption('size')) {
$finder->size($size);
}
if ($modified = $input->getOption('modified')) {
$finder->date($modified);
}
if ($depth = $input->getOption('depth')) {
$finder->depth($depth);
}
return $finder;
}
示例5: _parseIterator
/**
* @param \DOMNode $node
* @return \Iterator|null
*/
protected function _parseIterator(DOMNode $node)
{
$finder = new Finder();
$finder->files();
foreach ($node->childNodes as $option) {
if ($option->nodeType === XML_ELEMENT_NODE) {
$nodeName = strtolower($option->nodeName);
$value = $option->nodeValue;
switch ($nodeName) {
case 'name':
$finder->name($value);
break;
case 'notname':
$finder->notName($value);
break;
case 'path':
$finder->in($value);
break;
case 'size':
$finder->size($value);
break;
case 'exclude':
$finder->exclude($value);
break;
}
}
}
return $finder->getIterator();
}
示例6: size
/**
* @return Finder
*/
public function size($size)
{
return parent::size($size);
}