Domanda

How do I render assets through a filter (Closure) within a class, without people from the outside being able to see the file (i.e. not placing the file in the web folder). Should be possible as Assetic is able to do it.

I've already looked at the assetic code but I was not able to figure out how to do this.

È stato utile?

Soluzione

Kris Wallsmith (maker of assetic) helped me out doing this, and helped me in the right direction.

$asset = new FileAsset(__DIR__ . '/../Resources/assets/script.js');
$closureFilter = new CompilerJarFilter(
    $this->getContainer()->get('kernel')->getRootDir() . '/Resources/java/compiler.jar'
);
$closureFilter->setCompilationLevel(CompilerJarFilter::COMPILE_ADVANCED_OPTIMIZATIONS);
$asset->ensureFilter($closureFilter);
$script = $asset->dump();
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top