Template.php 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. namespace Sensio\Bundle\FrameworkExtraBundle\Configuration;
  3. use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
  4. /*
  5. * This file is part of the Symfony package.
  6. *
  7. * (c) Fabien Potencier <fabien@symfony.com>
  8. *
  9. * For the full copyright and license information, please view the LICENSE
  10. * file that was distributed with this source code.
  11. */
  12. /**
  13. * The Template class handles the @Template annotation parts.
  14. *
  15. * @author Fabien Potencier <fabien@symfony.com>
  16. * @Annotation
  17. */
  18. class Template extends ConfigurationAnnotation
  19. {
  20. /**
  21. * The template reference.
  22. *
  23. * @var TemplateReference
  24. */
  25. protected $template;
  26. /**
  27. * The template engine used when a specific template isnt specified
  28. *
  29. * @var string
  30. */
  31. protected $engine = 'twig';
  32. /**
  33. * The associative array of template variables.
  34. *
  35. * @var array
  36. */
  37. protected $vars = array();
  38. /**
  39. * Returns the array of templates variables.
  40. *
  41. * @return array
  42. */
  43. public function getVars()
  44. {
  45. return $this->vars;
  46. }
  47. /**
  48. * Sets the template variables
  49. *
  50. * @param array $vars The template variables
  51. */
  52. public function setVars($vars)
  53. {
  54. $this->vars = $vars;
  55. }
  56. /**
  57. * Returns the engine used when guessing template names
  58. *
  59. * @return string
  60. */
  61. public function getEngine()
  62. {
  63. return $this->engine;
  64. }
  65. /**
  66. * Sets the engine used when guessing template names
  67. *
  68. * @param string
  69. */
  70. public function setEngine($engine)
  71. {
  72. $this->engine = $engine;
  73. }
  74. /**
  75. * Sets the template logic name.
  76. *
  77. * @param string $template The template logic name
  78. */
  79. public function setValue($template)
  80. {
  81. $this->setTemplate($template);
  82. }
  83. /**
  84. * Returns the template reference.
  85. *
  86. * @return TemplateReference
  87. */
  88. public function getTemplate()
  89. {
  90. return $this->template;
  91. }
  92. /**
  93. * Sets the template reference.
  94. *
  95. * @param TemplateReference|string $template The template reference
  96. */
  97. public function setTemplate($template)
  98. {
  99. $this->template = $template;
  100. }
  101. /**
  102. * Returns the annotation alias name.
  103. *
  104. * @return string
  105. * @see ConfigurationInterface
  106. */
  107. public function getAliasName()
  108. {
  109. return 'template';
  110. }
  111. }