문제

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