1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Drupal\controller_annotations\Configuration; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* @Annotation |
7
|
|
|
*/ |
8
|
|
|
class Template extends ConfigurationAnnotation |
9
|
|
|
{ |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* The template reference. |
13
|
|
|
* |
14
|
|
|
* @var string |
15
|
|
|
*/ |
16
|
|
|
protected $template; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* The associative array of template variables. |
20
|
|
|
* |
21
|
|
|
* @var array |
22
|
|
|
*/ |
23
|
|
|
protected $vars = []; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Should the template be streamed? |
27
|
|
|
* |
28
|
|
|
* @var bool |
29
|
|
|
*/ |
30
|
|
|
protected $streamable = false; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* The controller (+action) this annotation is set to. |
34
|
|
|
* |
35
|
|
|
* @var array |
36
|
|
|
*/ |
37
|
|
|
private $owner; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Returns the array of templates variables. |
41
|
|
|
* |
42
|
|
|
* @return array |
43
|
|
|
*/ |
44
|
1 |
|
public function getVars() |
45
|
|
|
{ |
46
|
1 |
|
return $this->vars; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @param bool $streamable |
51
|
|
|
*/ |
52
|
|
|
public function setIsStreamable($streamable) |
53
|
|
|
{ |
54
|
|
|
$this->streamable = $streamable; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @return bool |
59
|
|
|
*/ |
60
|
1 |
|
public function isStreamable() |
61
|
|
|
{ |
62
|
1 |
|
return (bool)$this->streamable; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Sets the template variables. |
67
|
|
|
* |
68
|
|
|
* @param array $vars The template variables |
69
|
|
|
*/ |
70
|
|
|
public function setVars($vars) |
71
|
|
|
{ |
72
|
|
|
$this->vars = $vars; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Sets the template logic name. |
77
|
|
|
* |
78
|
|
|
* @param string $template The template logic name |
79
|
|
|
*/ |
80
|
6 |
|
public function setValue($template) |
81
|
|
|
{ |
82
|
6 |
|
$this->setTemplate($template); |
83
|
6 |
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Returns the template reference. |
87
|
|
|
* |
88
|
|
|
* @return string |
89
|
|
|
*/ |
90
|
3 |
|
public function getTemplate() |
91
|
|
|
{ |
92
|
3 |
|
return $this->template; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Sets the template reference. |
97
|
|
|
* |
98
|
|
|
* @param string $template The template reference |
99
|
|
|
*/ |
100
|
8 |
|
public function setTemplate($template) |
101
|
|
|
{ |
102
|
8 |
|
$this->template = $template; |
103
|
8 |
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Returns the annotation alias name. |
107
|
|
|
* |
108
|
|
|
* @return string |
109
|
|
|
* |
110
|
|
|
* @see ConfigurationInterface |
111
|
|
|
*/ |
112
|
1 |
|
public function getAliasName() |
113
|
|
|
{ |
114
|
1 |
|
return 'template'; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* Only one template directive is allowed. |
119
|
|
|
* |
120
|
|
|
* @return bool |
121
|
|
|
* |
122
|
|
|
* @see ConfigurationInterface |
123
|
|
|
*/ |
124
|
1 |
|
public function allowArray() |
125
|
|
|
{ |
126
|
1 |
|
return false; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @param array $owner |
131
|
|
|
*/ |
132
|
3 |
|
public function setOwner(array $owner) |
133
|
|
|
{ |
134
|
3 |
|
$this->owner = $owner; |
135
|
3 |
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* The controller (+action) this annotation is attached to. |
139
|
|
|
* |
140
|
|
|
* @return array |
141
|
|
|
*/ |
142
|
3 |
|
public function getOwner() |
143
|
|
|
{ |
144
|
3 |
|
return $this->owner; |
145
|
|
|
} |
146
|
|
|
} |
147
|
|
|
|