Staging.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /*
  3. * This file is part of Twig.
  4. *
  5. * (c) 2012 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. /**
  11. * Internal class.
  12. *
  13. * This class is used by Twig_Environment as a staging area and must not be used directly.
  14. *
  15. * @author Fabien Potencier <fabien@symfony.com>
  16. *
  17. * @internal
  18. */
  19. class Twig_Extension_Staging extends Twig_Extension
  20. {
  21. protected $functions = array();
  22. protected $filters = array();
  23. protected $visitors = array();
  24. protected $tokenParsers = array();
  25. protected $globals = array();
  26. protected $tests = array();
  27. public function addFunction($name, $function)
  28. {
  29. $this->functions[$name] = $function;
  30. }
  31. public function getFunctions()
  32. {
  33. return $this->functions;
  34. }
  35. public function addFilter($name, $filter)
  36. {
  37. $this->filters[$name] = $filter;
  38. }
  39. public function getFilters()
  40. {
  41. return $this->filters;
  42. }
  43. public function addNodeVisitor(Twig_NodeVisitorInterface $visitor)
  44. {
  45. $this->visitors[] = $visitor;
  46. }
  47. public function getNodeVisitors()
  48. {
  49. return $this->visitors;
  50. }
  51. public function addTokenParser(Twig_TokenParserInterface $parser)
  52. {
  53. $this->tokenParsers[] = $parser;
  54. }
  55. public function getTokenParsers()
  56. {
  57. return $this->tokenParsers;
  58. }
  59. public function addGlobal($name, $value)
  60. {
  61. $this->globals[$name] = $value;
  62. }
  63. public function getGlobals()
  64. {
  65. return $this->globals;
  66. }
  67. public function addTest($name, $test)
  68. {
  69. $this->tests[$name] = $test;
  70. }
  71. public function getTests()
  72. {
  73. return $this->tests;
  74. }
  75. public function getName()
  76. {
  77. return 'staging';
  78. }
  79. }