Method.php 828B

123456789101112131415161718192021222324252627282930313233343536
  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, $method;
  20. public function __construct(Twig_ExtensionInterface $extension, $method, array $options = array())
  21. {
  22. parent::__construct($options);
  23. $this->extension = $extension;
  24. $this->method = $method;
  25. }
  26. public function compile()
  27. {
  28. return sprintf('$this->env->getExtension(\'%s\')->%s', $this->extension->getName(), $this->method);
  29. }
  30. }