Method.php 842B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /*
  3. * This file is part of Twig.
  4. *
  5. * (c) 2009 Fabien Potencier
  6. * (c) 2010 Arnaud Le Blanc
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. /**
  12. * Represents a method template function.
  13. *
  14. * @package twig
  15. * @author Arnaud Le Blanc <arnaud.lb@gmail.com>
  16. */
  17. class Twig_Function_Method extends Twig_Function
  18. {
  19. protected $extension;
  20. protected $method;
  21. public function __construct(Twig_ExtensionInterface $extension, $method, array $options = array())
  22. {
  23. parent::__construct($options);
  24. $this->extension = $extension;
  25. $this->method = $method;
  26. }
  27. public function compile()
  28. {
  29. return sprintf('$this->env->getExtension(\'%s\')->%s', $this->extension->getName(), $this->method);
  30. }
  31. }