/**
  * 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);
         }
     }
 }
Example #2
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);
     }
 }
Example #3
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);
                 }
             }
         }
     }
 }
 /**
  * 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);
             }
         }
     }
 }