/** * @param AssetCollection $assetCollection * @return string */ public function renderCollection(AssetCollection $assetCollection) { $output = ""; foreach ($assetCollection->getAssets() as $asset) { $output .= $this->render($asset); } return $output; }
/** * Creates a new URL collection based on an asset collection. * * When debug mode is false there will only be one URL, regardless of * whether the collection is iterated over or echoed. * * @param AssetCollection $coll An asset collection * @param Boolean $debug The debug mode * * @return UrlCollection A new URL collection */ public static function createFromAssetCollection(AssetCollection $coll, $debug = false) { if ($debug) { $manyUrls = array(); foreach ($coll as $leaf) { $manyUrls[] = $leaf->getTargetUrl(); } } else { $manyUrls = array($coll->getTargetUrl()); } return new static($coll->getTargetUrl(), $manyUrls); }
/** * @return array */ public function getAssets() { return $this->assets->getAssets(); }
/** * Combines assets matching a pattern to a single file asset, optionally applies filters. * * @param AssetCollection $assets * @param string $name * @param array $options * @return AssetCollection */ protected function doCombine(AssetCollection $assets, $name, $options = []) { extract($options); $combine = new AssetCollection(); $pattern = $this->globToRegex($pattern); foreach ($assets as $asset) { if (preg_match($pattern, $asset->getName())) { $combine->add($asset); } } $file = strtr($this->cache, ['%name%' => $name]); if ($names = $combine->names() and $file = $this->doCache($combine, $file, $filters)) { $assets->remove(array_slice($names, 1)); $assets->replace(array_shift($names), $this->factory->create($name, $file)); } return $assets; }
static function yearEnd(&$errors) { $assets = new AssetCollection(DataObjectFactory::Factory('Asset')); $sh = new SearchHandler($assets, false); $assets->load($sh); if ($assets->count() > 0) { $db = DB::Instance(); $db->StartTrans(); foreach ($assets as $asset) { if (is_null($asset->disposal_date)) { $asset->bfwd_value = $asset->wd_value; $asset->ty_depn = 0; if (!$asset->save()) { $errors[] = 'Failed to update asset ' . $asset->code; } } if (count($errors) > 0) { break; } } if (count($errors) > 0) { $db->FailTrans(); } $db->CompleteTrans(); // TODO : display warning if no assets to depreciate // } else { // $errors[]='Failed to load assets'; } }