Method.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. @trigger_error('The Twig_Function_Method class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFunction instead.', E_USER_DEPRECATED);
  12. /**
  13. * Represents a method template function.
  14. *
  15. * Use Twig_SimpleFunction instead.
  16. *
  17. * @author Arnaud Le Blanc <arnaud.lb@gmail.com>
  18. *
  19. * @deprecated since 1.12 (to be removed in 2.0)
  20. */
  21. class Twig_Function_Method extends Twig_Function
  22. {
  23. protected $extension;
  24. protected $method;
  25. public function __construct(Twig_ExtensionInterface $extension, $method, array $options = array())
  26. {
  27. $options['callable'] = array($extension, $method);
  28. parent::__construct($options);
  29. $this->extension = $extension;
  30. $this->method = $method;
  31. }
  32. public function compile()
  33. {
  34. return sprintf('$this->env->getExtension(\'%s\')->%s', $this->extension->getName(), $this->method);
  35. }
  36. }