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