public function execute(InputInterface $input, OutputInterface $output)
 {
     $this->container = $this->getContainer();
     $this->assetic = $this->container->get('assetic.asset_manager');
     $files = array();
     foreach ($this->assetic->getNames() as $name) {
         $asset = $this->assetic->get($name);
         $group = array();
         foreach ($asset as $assetPart) {
             $absPath = realpath($assetPart->getSourceRoot() . '/' . $assetPart->getSourcePath());
             if ($absPath === false) {
                 continue;
             }
             $group[] = $assetPart->getTargetPath();
             $files[$assetPart->getTargetPath()] = $absPath;
         }
         $files[$asset->getTargetPath()] = $group;
     }
     switch ($input->getArgument('format')) {
         case 'json':
             $output->write(json_encode($files));
             break;
         default:
             $output->write(var_export($files, true));
             break;
     }
 }
Пример #2
0
 protected function createAssetManager()
 {
     $asset = new FileAsset(__DIR__ . '/../../../tests/test.css');
     $asset->setTargetPath('css/test.css');
     $assetManager = new AssetManager();
     $assetManager->set('test_css', $asset);
     return $assetManager;
 }
Пример #3
0
 /**
  * @param $name
  * @param bool $timestamp
  * @return mixed
  */
 public function url($name, $timestamp = true)
 {
     $asset = $this->assetManager->get($name);
     $params = ['filename' => $asset->getTargetPath()];
     if ($timestamp) {
         $params['v'] = $asset->getLastModified();
     }
     return $this->urlGenerator->generate('asset', $params);
 }
Пример #4
0
 public function build($collection_name)
 {
     $build_path_setting = Config::get("assetie::build_path");
     $build_directory = public_path() . DIRECTORY_SEPARATOR . $build_path_setting;
     /**
      * the designated name of the build, i.e. base_123.js
      */
     $build_name = $collection_name . "." . $this->buildExtension;
     $build_file = $build_directory . DIRECTORY_SEPARATOR . $build_name;
     $buildExists = file_exists($build_file);
     $build_url = URL::asset($build_path_setting . DIRECTORY_SEPARATOR . $build_name);
     $debugMode = Config::get("app.debug");
     if (!$buildExists || $debugMode) {
         $files = \Collection::dump($collection_name)[$this->group];
         $collection_hash = sha1(serialize($files));
         $hash_in_cache = Cache::get("collection_" . $this->group . "_" . $collection_name);
         $collectionChanged = $collection_hash != $hash_in_cache;
         $src_dir = app_path() . DIRECTORY_SEPARATOR . Config::get("assetie::directories." . $this->group) . DIRECTORY_SEPARATOR;
         $forceRebuild = false;
         if ($collectionChanged) {
             $forceRebuild = true;
         } else {
             if ($buildExists) {
                 /**
                  * only recompile if no compiled build exists or when in debug mode and
                  * build's source files or collections.php has been changed
                  */
                 $forceRebuild = $this->checkModification($build_file, $files, $src_dir);
             }
         }
         if (!$buildExists || $forceRebuild) {
             $am = new AssetManager();
             $assets = [];
             foreach ($files as $file) {
                 $filters = $this->getFilters($file);
                 $assets[] = new FileAsset($src_dir . $file, $filters);
             }
             $collection = new AssetCollection($assets);
             // , $filters
             $collection->setTargetPath($build_name);
             $am->set('collection', $collection);
             $writer = new AssetWriter($build_directory);
             $writer->writeManagerAssets($am);
         }
         // Cache::forever("collection_" . $collection_name, $collection_hash);
         $cache_key = "collection_" . $this->group . "_" . $collection_name;
         if (Cache::has($cache_key) && $collectionChanged) {
             Cache::forget($cache_key);
         }
         if ($collectionChanged) {
             Cache::put($cache_key, $collection_hash, 60);
             // 1 hour
         }
     }
     return $build_url;
 }
Пример #5
0
 public function writeManagerAssets(AssetManager $am)
 {
     foreach ($am->getNames() as $name) {
         $asset = $am->get($name);
         $path = $this->dir . '/' . $asset->getTargetPath();
         if (!file_exists($path) || filemtime($path) < $asset->getLastModified()) {
             $this->writeAsset($asset);
         }
     }
 }
Пример #6
0
 public function match(Http\IRequest $httpRequest)
 {
     $path = $httpRequest->getUrl()->getPath();
     foreach ($this->assetManager->getNames() as $name) {
         $asset = $this->assetManager->get($name);
         if ('/' . $asset->getTargetPath() === $path) {
             $this->dumpAsset($asset);
         }
     }
 }
 public function code_mirror_get_css_theme($parameters)
 {
     $am = new AssetManager();
     $am->set('theme', new FileAsset($parameters['theme']));
     $am->get('theme');
     #var_dump($am, $am->get('theme'), $am->getNames()); die;
     if (isset($parameters['theme']) and $theme = $this->assetManager->getTheme($parameters['theme'])) {
         return $theme;
     }
     return false;
 }
 public function testTwo()
 {
     $uglify = new UglifyJs2Filter("/usr/bin/uglifyjs", "/usr/bin/node");
     $uglify->setCompress(true);
     $uglify->setMangle(true);
     $uglify->setCompress(true);
     $am = new AssetManager();
     $am->set("app", new AssetCollection(array(new GlobAsset(__DIR__ . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "assets/src/*", array($uglify)))));
     echo $am->get("app")->dump();
     echo PHP_EOL;
 }
Пример #9
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('Dumping assets:');
     foreach ($this->assetManager->getNames() as $name) {
         $asset = $this->assetManager->get($name);
         $this->assetWriter->writeAsset($asset);
         $output->writeln("    <info>{$name}</info> -> <info>{$asset->getTargetPath()}</info>");
     }
     $count = count($this->assetManager->getNames());
     $output->writeln('');
     $output->writeln("Successfully dumped <info>{$count}</info> assets.");
 }
Пример #10
0
 /**
  * Writes an asset.
  *
  * If the application or asset is in debug mode, each leaf asset will be
  * dumped as well.
  *
  * @param string          $name   An asset name
  * @param OutputInterface $stdout The command output
  */
 public function dumpAsset($name, OutputInterface $stdout)
 {
     $asset = $this->am->get($name);
     $formula = $this->am->getFormula($name);
     // start by dumping the main asset
     $this->doDump($asset, $stdout);
     // dump each leaf if debug
     if (isset($formula[2]['debug']) ? $formula[2]['debug'] : $this->am->isDebug()) {
         foreach ($asset as $leaf) {
             $this->doDump($leaf, $stdout);
         }
     }
 }
Пример #11
0
 /**
  * @param array $options
  * @param string $name
  * @param Factory\AssetFactory $factory
  *
  * @return void
  */
 public function prepareCollection($options, $name, Factory\AssetFactory $factory)
 {
     $assets = isset($options['assets']) ? $options['assets'] : [];
     $filters = isset($options['filters']) ? $options['filters'] : [];
     $options = isset($options['options']) ? $options['options'] : [];
     $options['output'] = isset($options['output']) ? $options['output'] : $name;
     $moveRaw = isset($options['move_raw']) && $options['move_raw'];
     $targetPath = !empty($options['targetPath']) ? $options['targetPath'] : '';
     if (substr($targetPath, -1) != DIRECTORY_SEPARATOR) {
         $targetPath .= DIRECTORY_SEPARATOR;
     }
     $filters = $this->initFilters($filters);
     $asset = $factory->createAsset($assets, $filters, $options);
     // Allow to move all files 1:1 to new directory
     // its particularly useful when this assets are i.e. images.
     if ($moveRaw) {
         if (isset($options['disable_source_path'])) {
             $this->moveRaw($asset, $targetPath, $factory, $options['disable_source_path']);
         } else {
             $this->moveRaw($asset, $targetPath, $factory);
         }
     } else {
         $asset = $this->cacheAsset($asset);
         $this->assetManager->set($name, $asset);
         // Save asset on disk
         $this->writeAsset($asset, $factory);
     }
 }
Пример #12
0
 public function testMixture()
 {
     $asset = $this->getMock('Assetic\\Asset\\AssetInterface');
     $this->am->expects($this->any())->method('get')->with('foo')->will($this->returnValue($asset));
     $xml = $this->renderXml('mixture.twig');
     $this->assertEquals(1, count($xml->asset));
     $this->assertEquals('packed/mixture', (string) $xml->asset['url']);
 }
Пример #13
0
 /**
  * {@inheritdoc}
  */
 public function get($name)
 {
     try {
         return parent::get($name);
     } catch (\InvalidArgumentException $e) {
         return new FakeAsset($name);
     }
 }
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $this->container = $this->getContainer();
     $this->assetic = $this->container->get('assetic.asset_manager');
     $asset = $this->assetic->get($input->getArgument('group'));
     $allAssets = $asset->all();
     $content = null;
     if ($input->getArgument('index') !== false) {
         $subAsset = $allAssets[intval($input->getArgument('index')) - 1];
         $content = $this->dump($subAsset);
         echo $content;
     } else {
         foreach ($allAssets as $subAsset) {
             echo $this->dump($subAsset);
         }
     }
 }
Пример #15
0
 public function compress()
 {
     $am = new AssetManager();
     $am->set('jquery', new FileAsset($jsPath . '/jquery/jquery.js'));
     $am->set('base_css', new GlobAsset($cssPath . '/bootstrap/bootstrap.css'));
     $am->set('jquery_anytime', new AssetCollection(array(new AssetReference($am, 'jquery'), new FileAsset($jsPath . '/jquery/jquery.anytime.js'))));
     $fm = new FilterManager();
     $fm->set('yui_js', new Yui\JsCompressorFilter(__DIR__ . '/yuicompressor.jar', 'C:\\Program Files\\Java\\jdk1.7.0_09\\bin\\java.exe'));
     $factory = new AssetFactory(__DIR__);
     $factory->setAssetManager($am);
     $factory->setFilterManager($fm);
     $factory->setDebug(true);
     $js = $factory->createAsset(array('@jquery_anytime'), array(), array('output' => 'all.js'));
     $writer = new AssetWriter(__DIR__);
     $writer->writeAsset($js);
     //$css->setTargetPath(ASSETS);
     //$js->dump();
 }
 public function testDontFailIfNoTargetPathForReferenceAndNoUrl()
 {
     $asset = new PuliStringAsset('/css/style.css', 'body { background: blue; }');
     $asset->setTargetPath('/css/style.css');
     $asset->load();
     $asset2 = new PuliStringAsset('/images/bg.png', null);
     $this->am->set('asset2', $asset2);
     $this->filter->filterLoad($asset);
     $this->filter->filterDump($asset);
 }
Пример #17
0
    public function all()
    {
        foreach (array_keys($this->formulae) as $name) {
            if (!parent::has($name)) {
                $this->flush($name);
            }
        }

        return parent::all();
    }
Пример #18
0
 public function writeManagerAssets(AssetManager $am)
 {
     foreach ($am->getNames() as $name) {
         // pega as configuracoes de cada formula
         $combine = true;
         if ($am instanceof LazyAssetManager) {
             list($inputs, $filters, $options) = $am->getFormula($name);
             if (isset($options['combine'])) {
                 $combine = $options['combine'];
             } else {
                 if (isset($options['debug'])) {
                     $combine = !$options['debug'];
                 } else {
                     $combine = !$am->isDebug();
                 }
             }
         }
         $this->writeAsset($am->get($name), $combine);
     }
 }
Пример #19
0
 protected function dumpManagerAssets(AssetManager $am)
 {
     foreach ($am->getNames() as $name) {
         $asset = $am->get($name);
         if ($am instanceof LazyAssetManager) {
             $formula = $am->getFormula($name);
         }
         $dump = true;
         if ($this->watching) {
             // watching mode
             $dump = false;
             $resolved = VarUtils::resolve($asset->getTargetPath(), $asset->getVars(), $asset->getValues());
             $dest = $this->pathToWeb . '/' . $resolved;
             if (file_exists($dest)) {
                 $destmtime = filemtime($dest);
             } else {
                 $destmtime = 0;
             }
             // compare source and destination mtime
             if ($asset->getLastModified() > $destmtime) {
                 if ($this->commandOutput) {
                     $this->commandOutput->writeln("Dumping {$dest}");
                 }
                 $dump = true;
             }
         }
         if ($dump) {
             $this->writer->writeAsset($asset);
             if (!isset($formula[2])) {
                 continue;
             }
             $debug = isset($formula[2]['debug']) ? $formula[2]['debug'] : $am->isDebug();
             $combine = isset($formula[2]['combine']) ? $formula[2]['combine'] : null;
             if (null !== $combine ? !$combine : $debug) {
                 foreach ($asset as $leaf) {
                     $this->writer->writeAsset($leaf);
                 }
             }
         }
     }
 }
Пример #20
0
 /**
  * @param $fileName
  * @return AssetManager
  */
 public static function parseFromYaml($fileName)
 {
     $data = Yaml::parse($fileName);
     $am = new AssetManager();
     foreach ($data as $k => $v) {
         if (isset($v['assets'])) {
             $assets = [];
             foreach ((array) $v['assets'] as $asset) {
                 $source = isset($asset['source']) ? $asset['source'] : null;
                 $type = null;
                 if (isset($asset['type']) && in_array($asset['type'], self::$typeMap)) {
                     $type = self::$typeMap[$asset['type']];
                 } else {
                     $type = self::$typeMap['glob'];
                 }
                 $assets[] = new $type($source);
             }
             $assetCollection = new AssetCollection($assets);
             $am->set($k, $assetCollection);
         }
     }
     return $am;
 }
Пример #21
0
 public function setupRendererFromOptions(Renderer $renderer, array $options)
 {
     if (!$this->hasStrategyForRenderer($renderer)) {
         throw new \Exception(sprintf('no strategy defined for renderer "%s"', $this->getRendererName($renderer)));
     }
     /** @var $strategy \AsseticBundle\View\StrategyInterface */
     $strategy = $this->getStrategyForRenderer($renderer);
     while ($assetAlias = array_shift($options)) {
         $assetAlias = ltrim($assetAlias, '@');
         /** @var $asset \Assetic\Asset\AssetInterface */
         $asset = $this->assetManager->get($assetAlias);
         $strategy->setupAsset($asset);
     }
 }
Пример #22
0
 /**
  * Dump all assets
  */
 public function all()
 {
     foreach ($this->getAssetsXMLFiles() as $path => $XMLFile) {
         $this->out('');
         $this->out(sprintf('<info>Start dumping "%s" assets:</info>', $path));
         $xml = new Xml();
         $domDocument = $xml->build($XMLFile, ['return' => 'domdocument']);
         $xpath = new DOMXPath($domDocument);
         $assetsNodeList = $xpath->query('/assetic/assets/asset');
         $assetManager = new AssetManager();
         /** @var $assetNode DOMElement */
         foreach ($assetsNodeList as $assetNode) {
             $source = strtr($assetNode->getElementsByTagName('source')->item(0)->nodeValue, $this->paths);
             $destination = strtr($assetNode->getElementsByTagName('destination')->item(0)->nodeValue, $this->paths);
             $assetManager->set($assetNode->getAttribute('name'), $fileAsset = new FileAsset($source));
             $fileAsset->setTargetPath($destination);
             $this->out($source . ' <info> >>> </info> ' . WWW_ROOT . $destination);
         }
         $assetWriter = new AssetWriter(WWW_ROOT);
         $assetWriter->writeManagerAssets($assetManager);
         $this->dumpStaticFiles($domDocument);
         $this->out('<info>End</info>');
     }
 }
Пример #23
0
 /**
  * @param array $options
  * @param string $name
  * @param Factory\AssetFactory $factory
  * @return void
  */
 public function prepareCollection($options, $name, Factory\AssetFactory $factory)
 {
     $assets = isset($options['assets']) ? $options['assets'] : array();
     $filters = isset($options['filters']) ? $options['filters'] : $this->configuration->getDefault()['filters'];
     $options = isset($options['options']) ? $options['options'] : array();
     $options['output'] = isset($options['output']) ? $options['output'] : $name;
     $moveRaw = isset($options['move_raw']) && $options['move_raw'];
     $filters = $this->initFilters($filters);
     $asset = $factory->createAsset($assets, $filters, $options);
     // Allow to move all files 1:1 to new directory
     // its particularly useful when this assets are i.e. images.
     if ($moveRaw) {
         $this->moveRaw($asset);
     } else {
         $asset = $this->cacheAsset($asset);
         $this->assetManager->set($name, $asset);
     }
 }
Пример #24
0
 public function writeManagerAssets(AssetManager $am)
 {
     foreach ($am->getNames() as $name) {
         $this->writeAsset($am->get($name));
     }
 }
Пример #25
0
 /**
  * Add an asset reference to the asset manager
  *
  * @param string       $name    the name of the reference to be added
  * @param mixed        $assets  a string asset path, or an array of asset paths,
  *                              may include wildcard
  * @param string|array $filters either a comma separated list of known named filters
  *                              or an array of named filters and/or filter object
  *
  * @return boolean true if asset registers, false on error
  */
 public function registerAssetReference($name, $assets, $filters = null)
 {
     $xoops = \Xoops::getInstance();
     $assetArray = array();
     $filterArray = array();
     try {
         if (is_scalar($assets)) {
             $assets = array($assets);
             // just a single path name
         }
         foreach ($assets as $a) {
             // translate path if not a reference or absolute path
             if (substr_compare($a, '@', 0, 1) != 0 && substr_compare($a, '/', 0, 1) != 0) {
                 $a = $xoops->path($a);
             }
             if (false === strpos($a, '*')) {
                 $assetArray[] = new FileAsset($a);
                 // single file
             } else {
                 $assetArray[] = new GlobAsset($a);
                 // wild card match
             }
         }
         if (!is_array($filters)) {
             if (empty($filters)) {
                 $filters = array();
             } else {
                 $filters = explode(',', str_replace(' ', '', $filters));
             }
         }
         foreach ($filters as $filter) {
             if (is_object($filter) && $filter instanceof $this->filterInterface) {
                 $filterArray[] = $filter;
             } else {
                 switch (ltrim($filter, '?')) {
                     case 'cssembed':
                         $filterArray[] = new Filter\PhpCssEmbedFilter();
                         break;
                     case 'cssmin':
                         $filterArray[] = new Filter\CssMinFilter();
                         break;
                     case 'cssimport':
                         $filterArray[] = new Filter\CssImportFilter();
                         break;
                     case 'cssrewrite':
                         $filterArray[] = new Filter\CssRewriteFilter();
                         break;
                     case 'lessphp':
                         $filterArray[] = new Filter\LessphpFilter();
                         break;
                     case 'scssphp':
                         $filterArray[] = new Filter\ScssphpFilter();
                         break;
                     case 'jsmin':
                         $filterArray[] = new Filter\JSMinFilter();
                         break;
                     default:
                         throw new \Exception(sprintf('%s filter not implemented.', $filter));
                         break;
                 }
             }
         }
         $collection = new AssetCollection($assetArray, $filterArray);
         $this->assetManager->set($name, $collection);
         return true;
     } catch (\Exception $e) {
         $xoops->events()->triggerEvent('core.exception', $e);
         return false;
     }
 }
 /**
  * Filters an asset just before it's dumped.
  *
  * @param AssetInterface $asset An asset
  */
 public function filterDump(AssetInterface $asset)
 {
     if (!$asset instanceof PuliAsset) {
         return;
     }
     $pathMap = array();
     // Get a map of repository paths to target paths
     // e.g. "/webmozart/puli/images/bg.png" => "/images/bg.png"
     foreach ($this->am->getNames() as $name) {
         $this->extractTargetPaths($this->am->get($name), $pathMap);
     }
     // Remember the repository dir of the current resource
     $repoPath = $asset->getSourcePath();
     $repoDir = Path::getDirectory($repoPath);
     // Get the target directory of the current resource
     // e.g. "css"
     $targetPath = $asset->getTargetPath();
     $targetDir = Path::getDirectory($targetPath);
     // Convert to an absolute path so that we can create a proper
     // relative path later on
     // e.g. "/css"
     if (!Path::isAbsolute($targetDir)) {
         $targetDir = '/' . $targetDir;
     }
     $content = CssUtils::filterReferences($asset->getContent(), function ($matches) use($pathMap, $repoDir, $repoPath, $targetDir, $targetPath) {
         // The referenced path is a repository path
         // e.g. "/webmozart/puli/images/bg.png"
         $referencedPath = $matches['url'];
         // Ignore empty URLs
         if ('' === $referencedPath) {
             return $matches[0];
         }
         // Ignore non-local paths
         if (!Path::isLocal($referencedPath)) {
             return $matches[0];
         }
         // Ignore "data:" URLs
         if (0 === strpos($referencedPath, 'data:')) {
             return $matches[0];
         }
         // If the referenced path is not absolute, resolve it relative to
         // the directory of the source file
         if (!Path::isAbsolute($referencedPath)) {
             $referencedPath = Path::makeAbsolute($referencedPath, $repoDir);
         }
         // The referenced asset must be known
         if (!array_key_exists($referencedPath, $pathMap)) {
             throw new AssetException(sprintf('The asset "%s" referenced in "%s" could not be found.', $referencedPath, $repoPath));
         }
         // The target path of the referenced file must be set
         if (!$pathMap[$referencedPath]) {
             throw new AssetException(sprintf('The referenced path "%s" in "%s" cannot be resolved, because ' . 'the target path of "%s" is not set.', $matches['url'], $repoPath, $matches['url']));
         }
         // The target path of the source file must be set
         if (!$targetPath) {
             throw new AssetException(sprintf('The referenced path "%s" in "%s" cannot be resolved, because ' . 'the target path of "%s" is not set.', $matches['url'], $repoPath, $repoPath));
         }
         // Get the relative path from the source directory to the reference
         // e.g. "/css/style.css" + "/images/bg.png" = "../images/bg.png"
         $relativePath = Path::makeRelative($pathMap[$referencedPath], $targetDir);
         return str_replace($matches['url'], $relativePath, $matches[0]);
     });
     $asset->setContent($content);
 }
Пример #27
0
//header('Expires: 0'); // Proxies.
require_once __DIR__ . "/functions.php";
//require_once(__DIR__ . DIRECTORY_SEPARATOR . "autoloader.php");
use Assetic\Asset\FileAsset;
use Assetic\Asset\GlobAsset;
use Assetic\Asset\AssetCollection;
use Assetic\AssetManager;
use Assetic\Asset\AssetReference;
use Assetic\Filter\JSMinPlusFilter;
use Assetic\AssetWriter;
use Assetic\Cache\FilesystemCache;
use Assetic\Asset\AssetCache;
// Define the locations for the asset and cache directories
$assets = dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'assets';
$cache = $assets . DIRECTORY_SEPARATOR . 'cache';
$am = new AssetManager();
// Create asset refrences to jQuery and all the other js files in the JS folder
// Creating a refernce to jQuery will allow us to put it first in the file
$am->set('jquery', new AssetCache(new FileAsset($assets . DIRECTORY_SEPARATOR . 'jquery' . DIRECTORY_SEPARATOR . 'jquery-1.11.1.min.js'), new FilesystemCache($cache)));
$am->set('jquery_ui', new AssetCache(new FileAsset($assets . DIRECTORY_SEPARATOR . 'jquery' . DIRECTORY_SEPARATOR . 'jquery-ui-1.9.2.min.js'), new FilesystemCache($cache)));
$am->set('otherjs', new AssetCache(new GlobAsset($assets . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . '*.js'), new FilesystemCache($cache)));
//include guide.js if reffer is from guide.php
//if (isset( $_SERVER['HTTP_REFERER'])) {
//	$lobjSplit = explode( '/', $_SERVER['HTTP_REFERER']);
//  if( strpos($lobjSplit[count($lobjSplit) - 1], 'guide.php') !== FALSE && $lobjSplit[count($lobjSplit) - 2] == 'guides' )
//{
$am->set('guidejs', new AssetCache(new GlobAsset($assets . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . 'guides' . DIRECTORY_SEPARATOR . '*.js'), new FilesystemCache($cache)));
//   }
//} else { }
// Apply the JSMinPlus filter to all the files
$jquery = new AssetCollection(array(new AssetReference($am, 'jquery')));
Пример #28
0
 public function writeManagerAssets(AssetManager $am)
 {
     foreach ($am->all() as $asset) {
         $this->writeAsset($asset);
     }
 }
Пример #29
0
 public function getNames()
 {
     if (!$this->loaded) {
         $this->load();
     }
     return array_unique(array_merge(parent::getNames(), array_keys($this->formulae)));
 }
Пример #30
0
 /**
  * Dumps the assets of given manager
  *
  * Doesn't use AssetWriter::writeManagerAssets since we also want to dump non-combined assets
  * (for example, when using twig extension in debug mode).
  *
  * @param AssetManager $am
  * @param AssetWriter  $writer
  */
 protected function dumpManagerAssets(AssetManager $am)
 {
     foreach ($am->getNames() as $name) {
         $asset = $am->get($name);
         if ($am instanceof LazyAssetManager) {
             $formula = $am->getFormula($name);
         }
         $this->writer->writeAsset($asset);
         if (!isset($formula[2])) {
             continue;
         }
         $debug = isset($formula[2]['debug']) ? $formula[2]['debug'] : $am->isDebug();
         $combine = isset($formula[2]['combine']) ? $formula[2]['combine'] : null;
         if (null !== $combine ? !$combine : $debug) {
             foreach ($asset as $leaf) {
                 $this->writer->writeAsset($leaf);
             }
         }
     }
 }