/** * getAsset - render assets of a given type for a package * * @param string $name * @param sfDynamicsAssetCollectionDefinition $package * @param string $type * @return string */ public function getAsset($name, Dynamics_Configuration_Definition_AssetCollection $package, $type) { $extension = Dynamics::getExtensionFromType($type); $getAssets = 'get' . ucfirst($type) . 's'; if (count($assets = $package->{$getAssets}())) { $paths = $package->getPaths($this->configuration->getGlobalAssetPaths()); if ($this->configuration->isCacheEnabled()) { $cache = $this->configuration->getCacheService(); $cacheKey = $cache->generateKey($package, $type); if ($cache->has($cacheKey)) { if ($this->configuration->isCacheUpToDateCheckEnabled()) { if ($cache->isStillUpToDate($package, $type, $cacheKey)) { $result = $cache->get($cacheKey); } } else { $result = $cache->get($cacheKey); } } } // still no result? let's build it! if (!isset($result)) { $result = $this->configuration->getConcatenatedAssetFilterChainFor($type)->filter($this->getConcatenatedAssets($package, $paths, $assets)); if ($this->configuration->isCacheEnabled()) { $cache->set($cacheKey, $result); } } return $result; } else { return ''; } }
public function parseXml($xml) { $xml = parent::parseXml($xml); if (isset($xml->path)) { foreach ($xml->path as $path) { switch (isset($path['priority']) ? $path['priority'] : 'high') { case 'high': $this->appendPaths[] = $this->parsePath((string) $path); break; case 'low': $this->prependPaths[] = $this->parsePath((string) $path); break; default: throw new sfConfigurationException('Path «priority» attribute can only be «high» or «low».'); } } } if (isset($xml->require)) { foreach ($xml->require as $require) { $this->requires[] = (string) $require; } } if (isset($xml->conflict)) { foreach ($xml->conflict as $conflict) { $this->conflicts[] = (string) $conflict; } } if (isset($xml->i18n)) { foreach ($xml->i18n as $i18n) { if (!strlen($language = (string) $i18n['language'])) { throw new sfConfigurationException('Each I18n tag should have a language attribute.'); } $this->i18n[$language] = new sfDynamicsAssetCollectionDefinition($i18n); } } if (isset($xml->theme)) { $hasDefault = false; foreach ($xml->theme as $theme) { if (!strlen($themeName = (string) $theme['name'])) { throw new sfConfigurationException('Each theme tag should have a name attribute.'); } $this->themes[$themeName] = new sfDynamicsAssetCollectionDefinition($theme); } } return $xml; }