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.

有帮助吗?

解决方案

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();
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top