public function dump()
 {
     $finder = new Finder();
     $twigNamespaces = $this->loader->getNamespaces();
     foreach ($twigNamespaces as $ns) {
         if (count($this->loader->getPaths($ns)) > 0) {
             $iterator = $finder->files()->in($this->loader->getPaths($ns));
             foreach ($iterator as $file) {
                 /** @var SplFileInfo $file */
                 $resource = new TwigResource($this->loader, '@' . $ns . '/' . $file->getRelativePathname());
                 $this->lam->addResource($resource, 'twig');
             }
         }
     }
     foreach ($this->lam->getNames() as $name) {
         $asset = $this->lam->get($name);
         $formula = $this->lam->getFormula($name);
         $debug = isset($formula[2]['debug']) ? $formula[2]['debug'] : $this->lam->isDebug();
         $combine = isset($formula[2]['combine']) ? $formula[2]['combine'] : null;
         if (null !== $combine ? !$combine : $debug) {
             foreach ($asset as $leaf) {
                 $this->aw->writeAsset($leaf);
             }
         } else {
             $this->aw->writeAsset($asset);
         }
     }
 }
Example #2
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 $output The command output
  */
 private function dumpAsset($name, OutputInterface $output, array &$previously = array())
 {
     $formula = $this->am->getFormula($name);
     if ($this->debug) {
         if (isset($formula[2]['debug']) && !$formula[2]['debug'] && $this->am->isDebug()) {
             return;
         }
     }
     $asset = $this->am->get($name);
     // start by dumping the main asset
     $this->doDump($asset, $output);
     // dump each leaf if debug
     if (isset($formula[2]['debug']) ? $formula[2]['debug'] : $this->am->isDebug()) {
         foreach ($asset as $leaf) {
             $key = serialize($leaf);
             $mtime = $leaf->getLastModified();
             if (isset($previously[$key])) {
                 $changed = $previously[$key]['mtime'] != $mtime;
             } else {
                 $changed = true;
             }
             $previously[$key] = array('mtime' => $mtime);
             if ($changed) {
                 $this->doDump($leaf, $output);
             }
         }
     }
     if (!$this->debug) {
         // dump the main asset
         $this->doDump($asset, $output);
     }
 }
 /**
  * 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 $output The command output
  */
 private function dumpAsset($name, OutputInterface $output)
 {
     $asset = $this->am->get($name);
     $formula = $this->am->getFormula($name);
     if ($this->getConfig()->getEnv() != 'dev') {
         $this->doDump($asset, $output);
     }
     // dump each leaf if debug
     if (isset($formula[2]['debug']) ? $formula[2]['debug'] : $this->am->isDebug()) {
         foreach ($asset as $leaf) {
             $this->doDump($leaf, $output);
         }
     }
 }