public function collection($name, $collection = null, $create = null) { if (!is_null($collection)) { // $this->logger->debug(__CLASS__.'::'.__FUNCTION__.': adding collection instance to volume: '.$name); $this->collections[$name] = $collection; } if (isset($this->collections[$name])) { // $this->logger->debug(__CLASS__.'::'.__FUNCTION__.': returning abstract collection: '.$name); return $this->collections[$name]; } elseif (!is_null($create)) { // $this->logger->debug(__CLASS__.'::'.__FUNCTION__.': creating new abstract collection: '.$name); $collection = new Collection(); $collection->name($name); $collection->parent($this); $this->collections[$name] = $collection; return $this->collections[$name]; } return null; }
/** * Scan and cache the assets in a collection. * */ public function collect(\RS\Repose\Core\Objects\Collection $collection) { static::$logger->addInfo(__CLASS__ . '::' . __FUNCTION__ . ': Adding assets to hierarchy map: ' . $collection->parent()->name() . DS . $collection->name()); if (strpos($collection->parent()->name(), '.') !== 0) { $path = static::$disk->protocol() . $collection->parent()->name() . DS . $collection->name(); foreach (static::$manager->listContents($path, 0) as $info) { if (array_key_exists('extension', $info) && $info['extension'] === 'json') { continue; } // This does not return a "real" fully populated asset yet $service = new AssetService(new Asset(), $info); $asset = $service->asset(); $collection->add($asset->uuid(), $asset); } } }