Method.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /*
  3. * This file is part of Twig.
  4. *
  5. * (c) 2010 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_Test_Method class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleTest instead.', E_USER_DEPRECATED);
  11. /**
  12. * Represents a method template test.
  13. *
  14. * @author Fabien Potencier <fabien@symfony.com>
  15. *
  16. * @deprecated since 1.12 (to be removed in 2.0)
  17. */
  18. class Twig_Test_Method extends Twig_Test
  19. {
  20. protected $extension;
  21. protected $method;
  22. public function __construct(Twig_ExtensionInterface $extension, $method, array $options = array())
  23. {
  24. $options['callable'] = array($extension, $method);
  25. parent::__construct($options);
  26. $this->extension = $extension;
  27. $this->method = $method;
  28. }
  29. public function compile()
  30. {
  31. return sprintf('$this->env->getExtension(\'%s\')->%s', $this->extension->getName(), $this->method);
  32. }
  33. }