sortByChangedTime() public method

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.
See also: SortableIterator
public sortByChangedTime ( ) : Finder | Symfony\Component\Finder\SplFileInfo[]
return Finder | Symfony\Component\Finder\SplFileInfo[] The current Finder instance
Beispiel #1
2
 /**
  * @param string|callable $by
  * @return $this
  */
 public function sortBy($by = self::SORT_BY_NAME)
 {
     if (is_callable($by)) {
         $this->finder->sort($by);
         return $this;
     }
     switch (strtolower($by)) {
         case self::SORT_BY_NAME:
         case 'name':
             $this->finder->sortByName();
             break;
         case self::SORT_BY_CHANGED_TIME:
         case 'ctime':
             $this->finder->sortByChangedTime();
             break;
         case self::SORT_BY_ACCESSED_TIME:
         case 'atime':
             $this->finder->sortByAccessedTime();
             break;
         case self::SORT_BY_TYPE:
         case 'type':
             $this->finder->sortByType();
             break;
         case self::SORT_BY_MODIFIED_TIME:
         case 'mtime':
             $this->finder->sortByModifiedTime();
             break;
         default:
             throw new \InvalidArgumentException($by . ' is not a supported argument for sorting.');
     }
     return $this;
 }
Beispiel #2
0
 /**
  *
  * @param SpritePackageInterface[]|Package[] $packages
  * @return SpriteImage
  */
 public function find($packages)
 {
     // Get icons
     $sprites = [];
     foreach ($packages as $package) {
         foreach ($package->getPaths() as $path) {
             $finder = new Finder();
             $finder->sortByChangedTime();
             $finder->sortByAccessedTime();
             $finder->name('/\\.(png|jpg|gif)$/');
             foreach ($finder->in($path) as $fileInfo) {
                 $sprite = new SpriteImage($path, $fileInfo);
                 if (!array_key_exists($sprite->hash, $sprites)) {
                     // Add new sprite to set if hash does not exists
                     $sprites[$sprite->hash] = $sprite;
                 }
                 // Sprite with selected hash exists, just add package
                 if (!in_array($package, $sprites[$sprite->hash]->packages)) {
                     $sprites[$sprite->hash]->packages[] = $package;
                 }
             }
         }
     }
     return $sprites;
 }
Beispiel #3
0
 /**
  * @return Finder
  */
 public function sortByChangedTime()
 {
     return parent::sortByChangedTime();
 }