protected function utilCompileAssets($type = null) { $this->comment('Compiling registered asset bundles...'); Config::set('cms.enableAssetMinify', !$this->option('debug')); $combiner = CombineAssets::instance(); $bundles = $combiner->getBundles($type); if (!$bundles) { $this->comment('Nothing to compile!'); return; } if ($type) { $bundles = [$bundles]; } foreach ($bundles as $bundleType) { foreach ($bundleType as $destination => $assets) { $destination = File::symbolizePath($destination); $publicDest = File::localToPublic(realpath(dirname($destination))) . '/' . basename($destination); $combiner->combineToFile($assets, $destination); $shortAssets = implode(', ', array_map('basename', $assets)); $this->comment($shortAssets); $this->comment(sprintf(' -> %s', $publicDest)); } } if ($type === null) { $this->utilCompileLang(); } }
/** * Combines JavaScript and StyleSheet assets. * @param string $name Combined file code * @return string Combined content. */ public function combine($name) { try { if (!strpos($name, '-')) { throw new ApplicationException(Lang::get('system::lang.combiner.not_found', ['name' => $name])); } $parts = explode('-', $name); $cacheId = $parts[0]; $combiner = CombineAssets::instance(); return $combiner->getContents($cacheId); } catch (Exception $ex) { return '/* ' . $ex->getMessage() . ' */'; } }
public function testResetCache() { $combiner = CombineAssets::instance(); $this->assertNull($combiner->resetCache()); }