vendor/bundles/Symfony/Bundle/AsseticBundle/Twig/AsseticExtension.php
changeset 0 7f95f8617b0b
equal deleted inserted replaced
-1:000000000000 0:7f95f8617b0b
       
     1 <?php
       
     2 
       
     3 /*
       
     4  * This file is part of the Symfony framework.
       
     5  *
       
     6  * (c) Fabien Potencier <fabien@symfony.com>
       
     7  *
       
     8  * This source file is subject to the MIT license that is bundled
       
     9  * with this source code in the file LICENSE.
       
    10  */
       
    11 
       
    12 namespace Symfony\Bundle\AsseticBundle\Twig;
       
    13 
       
    14 use Assetic\Extension\Twig\AsseticExtension as BaseAsseticExtension;
       
    15 use Assetic\Factory\AssetFactory;
       
    16 
       
    17 /**
       
    18  * Assetic extension.
       
    19  *
       
    20  * @author Kris Wallsmith <kris@symfony.com>
       
    21  */
       
    22 class AsseticExtension extends BaseAsseticExtension
       
    23 {
       
    24     private $useController;
       
    25 
       
    26     public function __construct(AssetFactory $factory, $useController = false, $functions = array())
       
    27     {
       
    28         parent::__construct($factory, $functions);
       
    29 
       
    30         $this->useController = $useController;
       
    31     }
       
    32 
       
    33     public function getTokenParsers()
       
    34     {
       
    35         return array(
       
    36             new AsseticTokenParser($this->factory, 'javascripts', 'js/*.js', false, array('package')),
       
    37             new AsseticTokenParser($this->factory, 'stylesheets', 'css/*.css', false, array('package')),
       
    38             new AsseticTokenParser($this->factory, 'image', 'images/*', true, array('package')),
       
    39         );
       
    40     }
       
    41 
       
    42     public function getNodeVisitors()
       
    43     {
       
    44         return array(new AsseticNodeVisitor());
       
    45     }
       
    46 
       
    47     public function getGlobals()
       
    48     {
       
    49         $globals = parent::getGlobals();
       
    50         $globals['assetic']['use_controller'] = $this->useController;
       
    51 
       
    52         return $globals;
       
    53     }
       
    54 }