2 // src/Rapsys/PackBundle/Twig/PackExtension.php
3 namespace Rapsys\PackBundle\Twig
;
5 use Symfony\Component\HttpKernel\Config\FileLocator
;
6 use Symfony\Component\DependencyInjection\ContainerInterface
;
7 use Symfony\Component\Asset\PackageInterface
;
8 use Twig\Extension\AbstractExtension
;
10 class PackExtension
extends AbstractExtension
{
26 public function __construct(FileLocator
$locator, ContainerInterface
$container, PackageInterface
$package) {
28 $this->locator
= $locator;
31 $this->package
= $package;
33 //Retrieve bundle config
34 if ($parameters = $container->getParameter($this->getAlias())) {
35 //Set config, output and filters arrays
36 foreach(['config', 'output', 'filters'] as $k) {
37 $this->$k = $parameters[$k];
42 public function getTokenParsers() {
44 new PackTokenParser($this->locator
, $this->package
, $this->config
, 'stylesheet', $this->output
['css'], $this->filters
['css']),
45 new PackTokenParser($this->locator
, $this->package
, $this->config
, 'javascript', $this->output
['js'], $this->filters
['js']),
46 new PackTokenParser($this->locator
, $this->package
, $this->config
, 'image', $this->output
['img'], $this->filters
['img'])
53 public function getAlias() {