本文整理汇总了PHP中Symfony\Component\Finder\Finder::date方法的典型用法代码示例。如果您正苦于以下问题:PHP Finder::date方法的具体用法?PHP Finder::date怎么用?PHP Finder::date使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Finder\Finder
的用法示例。
在下文中一共展示了Finder::date方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
protected function execute(InputInterface $input, OutputInterface $outputInterface)
{
$finder = new Finder();
$table = new Table($outputInterface);
$table->setHeaders(["Název", "Velikost", "Datum modifikace"]);
if ($input->getOption("max-kbytes")) {
$finder->files()->size("< " . (int) $input->getOption("max-kbytes") . "K");
}
if ($input->getOption("name")) {
$finder->name((string) $input->getOption("name"));
}
if ($input->getOption("max-age")) {
$finder->date(">= -" . (int) $input->getOption("max-age") . " day");
}
foreach ($finder->in("tmp") as $key => $item) {
/** @var SplFileInfo $item */
$table->addRow([$item->getRelativePathname(), $item->isDir() ? "---" : round($item->getSize() / 1024, 1) . "kB", date("Y-m-d H:i:s", $item->getMTime())]);
}
$table->render();
}
示例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: cleanUp
public function cleanUp()
{
$finder = new Finder();
$finder->files()->in($this->queuePath)->ignoreDotFiles(true)->ignoreUnreadableDirs(true)->ignoreVCS(true)->depth('< 2')->name('*.json');
$finder->date(sprintf('> %d seconds ago', $this->options['message_expiration']));
/** @var SplFileInfo $file */
foreach ($finder as $file) {
@unlink($file->getRealPath());
}
}
示例4: 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.
//.........这里部分代码省略.........
示例5: getFinder
/**
*
* @return Finder
*/
protected function getFinder()
{
if (null === $this->finder) {
$finder = new Finder();
$settings = $this->getSettings();
foreach ($settings->getSrc() as $source) {
if (is_dir($source)) {
$finder->in($source);
}
if (is_file($source)) {
$finder->append(array($source));
}
}
if (true === $settings->getFollowLinks()) {
$finder->followLinks();
}
$finder->ignoreDotFiles($settings->getIgnoreDotFiles());
$finder->name($settings->getFileSuffix());
$finder->exclude($settings->getExclude());
if (NULL !== $settings->getDate()) {
$finder->date($settings->getDate());
}
$this->setFinder($finder);
}
return $this->finder;
}
示例6: 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;
}
示例7: date
/**
* @return Finder
*/
public function date($date)
{
return parent::date($date);
}