ExtensionReference.php 830B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /*
  3. * This file is part of Twig.
  4. *
  5. * (c) 2009 Fabien Potencier
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. /**
  11. * Represents an extension call node.
  12. *
  13. * @package twig
  14. * @author Fabien Potencier <fabien@symfony.com>
  15. */
  16. class Twig_Node_Expression_ExtensionReference extends Twig_Node_Expression
  17. {
  18. public function __construct($name, $lineno, $tag = null)
  19. {
  20. parent::__construct(array(), array('name' => $name), $lineno, $tag);
  21. }
  22. /**
  23. * Compiles the node to PHP.
  24. *
  25. * @param Twig_Compiler A Twig_Compiler instance
  26. */
  27. public function compile(Twig_Compiler $compiler)
  28. {
  29. $compiler->raw(sprintf("\$this->env->getExtension('%s')", $this->getAttribute('name')));
  30. }
  31. }