Method.php 1.1 KB

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