AsseticExtension.php 1.4KB

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