public function __construct() { $config = new stdClass(); $config->paths = new stdClass(); $config->paths->docroot = null; $config->site = new stdClass(); $config->site->mode = 'prod'; $config->site->cdnPrefix = 'a'; $config->defaults = new stdClass(); $config->defaults->cdnPrefix = ''; $config->defaults->mediaVersion = 'a'; parent::__construct(array('config' => $config)); if (class_exists('vfsStream')) { vfsStreamWrapper::register(); vfsStreamWrapper::setRoot(new vfsStreamDirectory('assetDir')); $config->paths->docroot = vfsStream::url('assetDir'); } $this->docroot = $config->paths->docroot; $this->cacheDir = sprintf('%s/assets/cache', $this->docroot); $this->assets = $this->assetsRel = array('js' => array(), 'css' => array()); $siteMode = $config->site->mode; if ($siteMode === 'prod') { $this->mode = self::minified; } else { $this->mode = self::combined; } $this->returnAsHeader = false; }
/** * Build link tags to one or more stylesheet assets * * @param mixed One or more assets, optionally followed by an * array describing options to apply to the tags * generated for these assets.<br> Each asset is a * string in one of the formats accepted as value * of the $source argument of * {@link stylesheet_path()}.<br> The optional last * argument is an array whose keys are names of * attributes of the link tag and whose corresponding * values are the values assigned to each * attribute. If omitted, options default to: * <ul> * <li>"rel" => "Stylesheet"</li> * <li>"type" => "text/css"</li> * <li>"media" => "screen"</li> * <li>"href" => <i>path-to-source</i></li> * </ul> * @return string A link tag for each asset in the argument list * @uses stylesheet_path() * @uses tag() */ function stylesheet_link_tag() { if (func_num_args() > 0) { $sources = func_get_args(); $options = is_array(end($sources)) ? array_pop($sources) : array(); $contents = array(); foreach ($sources as $source) { $ap = new AssetPipeline(); if ($source == 'application' && $ap->compile()) { $css_files = $ap->files_for_stylesheet_link_tag(); } else { $css_files = array($source); } foreach ($css_files as $css_file) { $source = $this->stylesheet_path($css_file); $contents[] = $this->tag("link", array_merge(array("rel" => "Stylesheet", "type" => "text/css", "media" => "screen", "href" => $source), $options)); } } return implode(" ", $contents); } }
protected function include_path_type() { return AssetPipeline::include_path_type($this->manifest_file); }