/** * Looks up the asset group name in your config and takes * all the files and settings from there * @param $name - the name of the asset set to load (a-z 0-9 _ and - only) * @return string * @throws \InvalidArgumentException */ public function handleAssets($name) { // clean the name $name = preg_replace('/[^a-z0-9-_]/u', '', strtolower($name)); // Get the name of the config key $key = 'assets.filesets.' . $name; // look the asset name up in the cache //$url = $this->cache->get($key); //if ($url != null) // return $url; // Check the file list is decent. $fileList = $this->config->get($key . '.files.*', array()); if (!is_array($fileList) || count($fileList) == 0) { throw new \InvalidArgumentException("Asset File list for '{$name}' is missing or empty. Can't generate asset files"); } // check that the type is one of the ones we support $type = $this->config->get($key . '.type', 'css'); if (!preg_match('/css|js/u', $type)) { throw new \InvalidArgumentException("Asset File list for '{$name}'' uses invalid type of '{$type}''"); } // built the filter list... $filters = array(); if ($type == 'css') { $filters = array(new CssMinifyFilter()); } // Build the target name $target = $name . '-%token%.' . $type; // Finally, generate the content, write it to the cache, and return it $url = $this->handleGeneralAssets($fileList, $target, $filters); $this->cache->set($key, $url, $this->cacheTime); return $url; }
public function __construct(KernelInterface $kernel) { // Perform the default construction parent::__construct($kernel); // Default the cached path to something sane // though we recommend that this be overridden in the service setup $this->setCacheFilename($this->getDefaultCacheFilename()); }