|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Drupal\controller_annotations\Configuration; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* @Annotation |
|
7
|
|
|
*/ |
|
8
|
|
|
class Cache extends ConfigurationAnnotation |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* The expiration date as a valid date for the strtotime() function. |
|
12
|
|
|
* |
|
13
|
|
|
* @var string |
|
14
|
|
|
*/ |
|
15
|
|
|
protected $expires; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* The number of seconds that the response is considered fresh by a private |
|
19
|
|
|
* cache like a web browser. |
|
20
|
|
|
* |
|
21
|
|
|
* @var int |
|
22
|
|
|
*/ |
|
23
|
|
|
protected $maxage; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* The number of seconds that the response is considered fresh by a public |
|
27
|
|
|
* cache like a reverse proxy cache. |
|
28
|
|
|
* |
|
29
|
|
|
* @var int |
|
30
|
|
|
*/ |
|
31
|
|
|
protected $smaxage; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Whether the response is public or not. |
|
35
|
|
|
* |
|
36
|
|
|
* @var bool |
|
37
|
|
|
*/ |
|
38
|
|
|
protected $public; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Additional "Vary:"-headers. |
|
42
|
|
|
* |
|
43
|
|
|
* @var array |
|
44
|
|
|
*/ |
|
45
|
|
|
protected $vary; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* An expression to compute the Last-Modified HTTP header. |
|
49
|
|
|
* |
|
50
|
|
|
* @var string |
|
51
|
|
|
*/ |
|
52
|
|
|
protected $lastModified; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* An expression to compute the ETag HTTP header. |
|
56
|
|
|
* |
|
57
|
|
|
* @var string |
|
58
|
|
|
*/ |
|
59
|
|
|
protected $etag; |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Returns the expiration date for the Expires header field. |
|
63
|
|
|
* |
|
64
|
|
|
* @return string |
|
65
|
|
|
*/ |
|
66
|
10 |
|
public function getExpires() |
|
67
|
|
|
{ |
|
68
|
10 |
|
return $this->expires; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Sets the expiration date for the Expires header field. |
|
73
|
|
|
* |
|
74
|
|
|
* @param string $expires A valid php date |
|
75
|
|
|
*/ |
|
76
|
2 |
|
public function setExpires($expires) |
|
77
|
|
|
{ |
|
78
|
2 |
|
$this->expires = $expires; |
|
79
|
2 |
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* Sets the number of seconds for the max-age cache-control header field. |
|
83
|
|
|
* |
|
84
|
|
|
* @param int $maxage A number of seconds |
|
85
|
|
|
*/ |
|
86
|
3 |
|
public function setMaxAge($maxage) |
|
87
|
|
|
{ |
|
88
|
3 |
|
$this->maxage = $maxage; |
|
89
|
3 |
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Returns the number of seconds the response is considered fresh by a |
|
93
|
|
|
* private cache. |
|
94
|
|
|
* |
|
95
|
|
|
* @return int |
|
96
|
|
|
*/ |
|
97
|
10 |
|
public function getMaxAge() |
|
98
|
|
|
{ |
|
99
|
10 |
|
return $this->maxage; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* Sets the number of seconds for the s-maxage cache-control header field. |
|
104
|
|
|
* |
|
105
|
|
|
* @param int $smaxage A number of seconds |
|
106
|
|
|
*/ |
|
107
|
3 |
|
public function setSMaxAge($smaxage) |
|
108
|
|
|
{ |
|
109
|
3 |
|
$this->smaxage = $smaxage; |
|
110
|
3 |
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* Returns the number of seconds the response is considered fresh by a |
|
114
|
|
|
* public cache. |
|
115
|
|
|
* |
|
116
|
|
|
* @return int |
|
117
|
|
|
*/ |
|
118
|
10 |
|
public function getSMaxAge() |
|
119
|
|
|
{ |
|
120
|
10 |
|
return $this->smaxage; |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* Returns whether or not a response is public. |
|
125
|
|
|
* |
|
126
|
|
|
* @return bool |
|
127
|
|
|
*/ |
|
128
|
10 |
|
public function isPublic() |
|
129
|
|
|
{ |
|
130
|
10 |
|
return $this->public === true; |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* Returns whether or not a response is private. |
|
135
|
|
|
* |
|
136
|
|
|
* @return bool |
|
137
|
|
|
*/ |
|
138
|
10 |
|
public function isPrivate() |
|
139
|
|
|
{ |
|
140
|
10 |
|
return $this->public === false; |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* Sets a response public. |
|
145
|
|
|
* |
|
146
|
|
|
* @param bool $public A boolean value |
|
147
|
|
|
*/ |
|
148
|
3 |
|
public function setPublic($public) |
|
149
|
|
|
{ |
|
150
|
3 |
|
$this->public = (bool) $public; |
|
151
|
3 |
|
} |
|
152
|
|
|
|
|
153
|
|
|
/** |
|
154
|
|
|
* Returns the custom "Vary"-headers. |
|
155
|
|
|
* |
|
156
|
|
|
* @return array |
|
157
|
|
|
*/ |
|
158
|
10 |
|
public function getVary() |
|
159
|
|
|
{ |
|
160
|
10 |
|
return $this->vary; |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
/** |
|
164
|
|
|
* Add additional "Vary:"-headers. |
|
165
|
|
|
* |
|
166
|
|
|
* @param array $vary |
|
167
|
|
|
*/ |
|
168
|
2 |
|
public function setVary($vary) |
|
169
|
|
|
{ |
|
170
|
2 |
|
$this->vary = $vary; |
|
171
|
2 |
|
} |
|
172
|
|
|
|
|
173
|
|
|
/** |
|
174
|
|
|
* Sets the "Last-Modified"-header expression. |
|
175
|
|
|
* |
|
176
|
|
|
* @param string $expression |
|
177
|
|
|
*/ |
|
178
|
3 |
|
public function setLastModified($expression) |
|
179
|
|
|
{ |
|
180
|
3 |
|
$this->lastModified = $expression; |
|
181
|
3 |
|
} |
|
182
|
|
|
|
|
183
|
|
|
/** |
|
184
|
|
|
* Returns the "Last-Modified"-header expression. |
|
185
|
|
|
* |
|
186
|
|
|
* @return string |
|
187
|
|
|
*/ |
|
188
|
5 |
|
public function getLastModified() |
|
189
|
|
|
{ |
|
190
|
5 |
|
return $this->lastModified; |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
|
|
/** |
|
194
|
|
|
* Sets the "ETag"-header expression. |
|
195
|
|
|
* |
|
196
|
|
|
* @param string $expression |
|
197
|
|
|
*/ |
|
198
|
3 |
|
public function setETag($expression) |
|
199
|
|
|
{ |
|
200
|
3 |
|
$this->etag = $expression; |
|
201
|
3 |
|
} |
|
202
|
|
|
|
|
203
|
|
|
/** |
|
204
|
|
|
* Returns the "ETag"-header expression. |
|
205
|
|
|
* |
|
206
|
|
|
* @return string |
|
207
|
|
|
*/ |
|
208
|
5 |
|
public function getETag() |
|
209
|
|
|
{ |
|
210
|
5 |
|
return $this->etag; |
|
211
|
|
|
} |
|
212
|
|
|
|
|
213
|
|
|
/** |
|
214
|
|
|
* Returns the annotation alias name. |
|
215
|
|
|
* |
|
216
|
|
|
* @return string |
|
217
|
|
|
* |
|
218
|
|
|
* @see ConfigurationInterface |
|
219
|
|
|
*/ |
|
220
|
1 |
|
public function getAliasName() |
|
221
|
|
|
{ |
|
222
|
1 |
|
return 'cache'; |
|
223
|
|
|
} |
|
224
|
|
|
|
|
225
|
|
|
/** |
|
226
|
|
|
* Only one cache directive is allowed. |
|
227
|
|
|
* |
|
228
|
|
|
* @return bool |
|
229
|
|
|
* |
|
230
|
|
|
* @see ConfigurationInterface |
|
231
|
|
|
*/ |
|
232
|
1 |
|
public function allowArray() |
|
233
|
|
|
{ |
|
234
|
1 |
|
return false; |
|
235
|
|
|
} |
|
236
|
|
|
} |
|
237
|
|
|
|