*/ class LazyAssetManager extends AssetManager { private $factory; private $loaders; private $resources; private $formulae; private $loaded; private $loading; /** * Constructor. * * @param AssetFactory $factory The asset factory * @param array $loaders An array of loaders indexed by alias */ public function __construct(AssetFactory $factory, $loaders = array()) { $this->factory = $factory; $this->loaders = array(); $this->resources = array(); $this->formulae = array(); $this->loaded = false; $this->loading = false; foreach ($loaders as $alias => $loader) { $this->setLoader($alias, $loader); } } /** * Adds a loader to the asset manager. * * @param string $alias An alias for the loader * @param FormulaLoaderInterface $loader A loader */ public function setLoader($alias, FormulaLoaderInterface $loader) { $this->loaders[$alias] = $loader; $this->loaded = false; } /** * Adds a resource to the asset manager. * * @param ResourceInterface $resource A resource * @param string $loader The loader alias for this resource */ public function addResource(ResourceInterface $resource, $loader) { $this->resources[$loader][] = $resource; $this->loaded = false; } /** * Returns an array of resources. * * @return array An array of resources */ public function getResources() { $resources = array(); foreach ($this->resources as $r) { $resources = array_merge($resources, $r); } return $resources; } /** * Checks for an asset formula. * * @param string $name An asset name * * @return Boolean If there is a formula */ public function hasFormula($name) { if (!$this->loaded) { $this->load(); } return isset($this->formulae[$name]); } /** * Returns an asset's formula. * * @param string $name An asset name * * @return array The formula * * @throws InvalidArgumentException If there is no formula by that name */ public function getFormula($name) { if (!$this->loaded) { $this->load(); } if (!isset($this->formulae[$name])) { throw new \InvalidArgumentException(sprintf('There is no "%s" formula.', $name)); } return $this->formulae[$name]; } /** * Sets a formula on the asset manager. * * @param string $name An asset name * @param array $formula A formula */ public function setFormula($name, array $formula) { $this->formulae[$name] = $formula; } /** * Loads formulae from resources. * * @throws LogicException If a resource has been added to an invalid loader */ public function load() { if ($this->loading) { return; } if ($diff = array_diff(array_keys($this->resources), array_keys($this->loaders))) { throw new \LogicException('The following loader(s) are not registered: '.implode(', ', $diff)); } $this->loading = true; foreach ($this->resources as $loader => $resources) { foreach ($resources as $resource) { $this->formulae = array_replace($this->formulae, $this->loaders[$loader]->load($resource)); } } $this->loaded = true; $this->loading = false; } public function get($name) { if (!$this->loaded) { $this->load(); } if (!parent::has($name) && isset($this->formulae[$name])) { list($inputs, $filters, $options) = $this->formulae[$name]; $options['name'] = $name; parent::set($name, $this->factory->createAsset($inputs, $filters, $options)); } return parent::get($name); } public function has($name) { if (!$this->loaded) { $this->load(); } return isset($this->formulae[$name]) || parent::has($name); } public function getNames() { if (!$this->loaded) { $this->load(); } return array_unique(array_merge(parent::getNames(), array_keys($this->formulae))); } public function isDebug() { return $this->factory->isDebug(); } } __halt_compiler();----SIGNATURE:----I3NyPWz55yniiaYxKU2a22m+5GoC4QZKMe53ikrzj2sHd/wmliaHFHItrqYOPfoouHgeP9WFpR8aBhXH0iOAhUauMZxdXLZTVl2x7eYsqsXXxG+SFanP6W8dq2fObCrY7x0QGXyRKYUrt8spl72a18HRcrS35aadVO69qdKtzReZqa4270JNpkt8UT4OwapFlYKcL/Lsi+NNu25pTAdW/T/9LAZQYEg9fmgx+flGhUALx8pn8klLLJ/zB70Pvw08wrVEHm8Cun0CT0Uit+UgRxLkiyNcbXWHQTc7K2AAOu4+O3/7yWYEJO4Qy2BUlFuyA4+yfdtTN4mi6eMkHLjhwte0iz341UmqINipy13WFdQZyggOxRhUgCfufVqCZOixe9XH79PfOsn69Bh5WC5grHQk5/DePKKFx0n0zYvvmUeridNU+bEzn3mVbMw+gmjhf0PmOuSFANJQkcon9/grWKbnFkDlX2ehsANo+n9+PtQtogPSLUid0mTjXDS0YE4Aii32tiGvYrEWfNouftVVxL1HKCC62RptKCCCbJ7AQFwxa83RBowfZRuVibZ+xj1JBgAcwkp8K9LhI55onVEeQsUMPpwMAtKznvgJNzzQpj6v6Z3dzeQfjg4nLJUTMWI4CkbN1sQPty8/LJtj1kqtRZEzQq3v4v+c5CbKAK7h4Og=----ATTACHMENT:----ODgyNzc4ODkwNDc4ODQ2IDQ1OTQzNjMzMjk3NTMyNDYgNzUwNTE5MjU5OTI5MTYwMg==