Ejemplo n.º 1
0
 public function volume($name = null, $create = null)
 {
     if (isset($this->volumes[$name])) {
         //            $this->logger->debug(__CLASS__.'::'.__FUNCTION__.': returning abstract volume: '.$name);
         return $this->volumes[$name];
     } elseif (!is_null($create)) {
         //            $this->logger->debug(__CLASS__.'::'.__FUNCTION__.': creating new abstract volume: '.$name);
         $volume = new Volume();
         $volume->name($name);
         $volume->parent($this);
         $this->addVolume($volume);
         return $this->volumes[$name];
     }
     return null;
 }
Ejemplo n.º 2
0
 public function initDiskMap()
 {
     $disk = new Disk();
     $disk->name('default');
     $disk->protocol('default://');
     $disk->root($this->config->get('default.local'));
     static::$logger->addInfo(__CLASS__ . '::' . __FUNCTION__ . ': Building disk-volume-collection tree: root: ' . $disk->root());
     foreach (static::$manager->listContents($disk->protocol(), 0) as $dir) {
         if (strpos($dir['path'], '.') !== 0) {
             $volume = new Volume();
             $volume->name($dir['path']);
             $volume->parent($disk);
             foreach (static::$manager->listContents($disk->protocol() . $volume->name(), 0) as $coll) {
                 if (strpos($coll['path'], '.') !== 0) {
                     $coll_name = str_replace($volume->name() . DS, '', $coll['path']);
                     $collection = new Collection();
                     $collection->name($coll_name);
                     $collection->parent($volume);
                     $volume->collection($collection->name(), $collection);
                 }
             }
             $disk->addVolume($volume);
         }
     }
     static::$disk = $disk;
     //        static::$logger->addDebug( __CLASS__.'::'.__FUNCTION__.': DISK: '.static::$disk);
     // scan in the assets too ?
     if ($this->config->get('cache.policy') === 'deep') {
         foreach ($disk->volumes() as $volume) {
             foreach ($volume->collections() as $collection) {
                 // scan the asset files too
                 $this->collect($collection);
             }
         }
     }
 }