示例#1
0
 /**
  * {@inheritdoc}
  */
 public function listContents($directory = '', $recursive = false)
 {
     $directory = $this->normalizePath($directory);
     try {
         $contents = $this->getAdapter()->listContents($directory, $recursive);
     } catch (Exception $e) {
         throw $this->handleEx($e, $directory);
     }
     $formatter = new Flysystem\Util\ContentListingFormatter($directory, $recursive);
     $contents = $formatter->formatListing($contents);
     $contents = array_map(function ($entry) {
         $type = $this->getTypeFromMetadata($entry);
         $entry['type'] = $type;
         if ($type === 'dir') {
             $handler = new Handler\Directory($this, $entry['path']);
         } elseif ($type === 'image') {
             $handler = Handler\Image::createFromListingEntry($this, $entry);
         } else {
             $handler = Handler\File::createFromListingEntry($this, $entry);
         }
         $handler->setMountPoint($this->mountPoint);
         return $handler;
     }, $contents);
     return $contents;
 }
示例#2
0
 /**
  * @inheritdoc
  */
 public function listContents($directory = '', $recursive = false)
 {
     $directory = Util::normalizePath($directory);
     $contents = $this->getAdapter()->listContents($directory, $recursive);
     $formatter = new ContentListingFormatter($directory, $recursive);
     return $formatter->formatListing($contents);
 }