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
 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
0
파일: pi.get_files.php 프로젝트: nob/joi
 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 <.
     |
     */
     if ($file_date) {
         $finder->date($file_date);
     }
     /*
     |--------------------------------------------------------------------------
     | Depth
     |--------------------------------------------------------------------------
     |
     | Recursively traverse directories, starting at 0.
     |
     */
     if ($depth) {
         $finder->depth($depth);
     }
     $matches = $finder->files();
     /*
     |--------------------------------------------------------------------------
     | Return and Parse
     |--------------------------------------------------------------------------
     |
     | This tag returns the matched filenames mapped to {{ file }}.
     |
     */
     $files = array();
     foreach ($matches as $file) {
         $files[] = array('file' => '/' . $in . '/' . $file->getRelativePathname());
         // $files[] = YAML::parse($file->getContents());
     }
     return Parse::tagLoop($this->content, $files);
 }
예제 #3
0
 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());
     }
 }
 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.
     |
     */
     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 <.
     |
     */
     if ($file_date) {
         $finder->date($file_date);
     }
     /*
     |--------------------------------------------------------------------------
     | Depth
     |--------------------------------------------------------------------------
     |
     | Recursively traverse directories, starting at 0.
     |
     */
     if ($depth) {
         $finder->depth($depth);
     }
     /*
     |--------------------------------------------------------------------------
     | Sort By
     |--------------------------------------------------------------------------
     |
     | Sort by name, file, or type
     |
     */
     if ($sort_by) {
         if ($sort_by === 'file' || $sort_by === 'name') {
             $finder->sortByName();
         } elseif ($sort_by === 'type') {
             $finder->sortByType();
         }
     }
     /*
     |--------------------------------------------------------------------------
     | Assemble File Array
     |--------------------------------------------------------------------------
     |
     | Select the important bits of data on the list of files.
     |
     */
     $matches = $finder->files()->followLinks();
     $files = array();
     foreach ($matches as $file) {
         $files[] = array('extension' => $file->getExtension(), 'filename' => $file->getFilename(), 'file' => Path::toAsset($file->getPathname()), 'name' => Path::toAsset($file->getPathname()), 'size' => File::getHumanSize($file->getSize()), 'size_bytes' => $file->getSize(), 'size_kilobytes' => number_format($file->getSize() / 1024, 2), 'size_megabytes' => number_format($file->getSize() / 1048576, 2), 'size_gigabytes' => number_format($file->getSize() / 1073741824, 2), 'is_image' => File::isImage($file->getPathname()));
     }
     /*
     |--------------------------------------------------------------------------
     | Sort Direction
     |--------------------------------------------------------------------------
     |
     | Set the sort direction, defaulting to "asc" (ascending)
     |
     */
     if ($sort_dir === 'desc') {
         $files = array_reverse($files);
     }
     /*
     |--------------------------------------------------------------------------
     | Randomizing
     |--------------------------------------------------------------------------
     |
     | You can't sort randomly using Symfony finder, so we'll do it manually.
     |
     */
     if ($sort_by === 'random') {
         shuffle($files);
     }
     /*
     |--------------------------------------------------------------------------
     | Limit Files
     |--------------------------------------------------------------------------
     |
     | Limit the number of files returned. Needs to be run after sort_dir to 
     | ensure consistency.
     |
     */
     if ($limit) {
         $files = array_slice($files, 0, $limit);
     }
     return Parse::tagLoop($this->content, $files, true, $this->context);
 }
예제 #5
0
 /**
  *
  * @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
0
 /**
  * @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
0
파일: Finder.php 프로젝트: stopsopa/utils
 /**
  * @return Finder
  */
 public function date($date)
 {
     return parent::date($date);
 }