/** * Get the final build file name for a target. * * @param AssetTarget $target The target to get a name for. * @return string */ public function buildFileName(AssetTarget $target) { $file = $target->name(); if ($target->isThemed() && $this->theme) { $file = $this->theme . '-' . $file; } return $file; }
/** * Get the dynamic build path for an asset. * * This generates URLs that work with the development dispatcher filter. * * @param string $file The build file you want to make a url for. * @param string $base The base path to fetch a url with. * @return string Generated URL. */ protected function _getRoute(AssetTarget $file, $base) { $query = []; if ($file->isThemed()) { $query['theme'] = $this->theme; } $base = rtrim($base, '/') . '/'; $query = empty($query) ? '' : '?' . http_build_query($query); return $base . $file->name() . $query; }
/** * Append an asset to the collection. * * @param AssetTarget $target The target to append * @return void */ public function append(AssetTarget $target) { $name = $target->name(); $this->indexed[$name] = $target; $this->items[] = $name; }
/** * Get a filter collection for a specific target. * * @param MiniAsset\AssetTarget $target The target to get a filter collection for. * @param boolean $debug Indicates whether it is in debug or production mode * @return MiniAsset\Filter\FilterCollection */ public function collection(AssetTarget $target, $debug = false) { $filters = []; foreach ($target->filterNames() as $name) { $filter = $this->get($name); if ($filter === null) { throw new RuntimeException("Filter '{$name}' was not loaded/configured."); } // Clone filters so the registry is not polluted. $copy = clone $filter; $copy->settings(['target' => $target->name(), 'paths' => $target->paths()]); $filters[] = $copy; } return new FilterCollection($filters, $debug); }
/** * Get the final filename for a build. Resolves * theme prefixes and timestamps. * * @param AssetTarget $target The build target name. * @return string The build filename to cache on disk. */ public function buildFileName(AssetTarget $target, $timestamp = true) { $file = $target->name(); if ($target->isThemed() && $this->theme) { $file = $this->theme . '-' . $file; } if ($timestamp) { $time = $this->getTimestamp($target); $file = $this->_timestampFile($file, $time); } return $file; }