Question

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.

Was it helpful?

Solution

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();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top