|
0
|
1 |
<?php |
|
|
2 |
|
|
|
3 |
namespace Sensio\Bundle\FrameworkExtraBundle\Configuration; |
|
|
4 |
|
|
|
5 |
/* |
|
|
6 |
* This file is part of the Symfony package. |
|
|
7 |
* |
|
|
8 |
* (c) Fabien Potencier <fabien@symfony.com> |
|
|
9 |
* |
|
|
10 |
* For the full copyright and license information, please view the LICENSE |
|
|
11 |
* file that was distributed with this source code. |
|
|
12 |
*/ |
|
|
13 |
|
|
|
14 |
/** |
|
|
15 |
* The Cache class handles the @Cache annotation parts. |
|
|
16 |
* |
|
|
17 |
* @author Fabien Potencier <fabien@symfony.com> |
|
|
18 |
* @Annotation |
|
|
19 |
*/ |
|
|
20 |
class Cache extends ConfigurationAnnotation |
|
|
21 |
{ |
|
|
22 |
/** |
|
|
23 |
* The expiration date as a valid date for the strtotime() function. |
|
|
24 |
* |
|
|
25 |
* @var string |
|
|
26 |
*/ |
|
|
27 |
protected $expires; |
|
|
28 |
|
|
|
29 |
/** |
|
|
30 |
* The number of seconds that the response is considered fresh by a private |
|
|
31 |
* cache like a web browser. |
|
|
32 |
* |
|
|
33 |
* @var integer |
|
|
34 |
*/ |
|
|
35 |
protected $maxage; |
|
|
36 |
|
|
|
37 |
/** |
|
|
38 |
* The number of seconds that the response is considered fresh by a public |
|
|
39 |
* cache like a reverse proxy cache. |
|
|
40 |
* |
|
|
41 |
* @var integer |
|
|
42 |
*/ |
|
|
43 |
protected $smaxage; |
|
|
44 |
|
|
|
45 |
/** |
|
|
46 |
* Whether or not the response is public or not. |
|
|
47 |
* |
|
|
48 |
* @var integer |
|
|
49 |
*/ |
|
|
50 |
protected $public; |
|
|
51 |
|
|
|
52 |
/** |
|
|
53 |
* Returns the expiration date for the Expires header field. |
|
|
54 |
* |
|
|
55 |
* @return string |
|
|
56 |
*/ |
|
|
57 |
public function getExpires() |
|
|
58 |
{ |
|
|
59 |
return $this->expires; |
|
|
60 |
} |
|
|
61 |
|
|
|
62 |
/** |
|
|
63 |
* Sets the expiration date for the Expires header field. |
|
|
64 |
* |
|
|
65 |
* @param string $expires A valid php date |
|
|
66 |
*/ |
|
|
67 |
public function setExpires($expires) |
|
|
68 |
{ |
|
|
69 |
$this->expires = $expires; |
|
|
70 |
} |
|
|
71 |
|
|
|
72 |
/** |
|
|
73 |
* Sets the number of seconds for the max-age cache-control header field. |
|
|
74 |
* |
|
|
75 |
* @param integer $maxage A number of seconds |
|
|
76 |
*/ |
|
|
77 |
public function setMaxAge($maxage) |
|
|
78 |
{ |
|
|
79 |
$this->maxage = $maxage; |
|
|
80 |
} |
|
|
81 |
|
|
|
82 |
/** |
|
|
83 |
* Returns the number of seconds the response is considered fresh by a |
|
|
84 |
* private cache. |
|
|
85 |
* |
|
|
86 |
* @return integer |
|
|
87 |
*/ |
|
|
88 |
public function getMaxAge() |
|
|
89 |
{ |
|
|
90 |
return $this->maxage; |
|
|
91 |
} |
|
|
92 |
|
|
|
93 |
/** |
|
|
94 |
* Sets the number of seconds for the s-maxage cache-control header field. |
|
|
95 |
* |
|
|
96 |
* @param integer $smaxage A number of seconds |
|
|
97 |
*/ |
|
|
98 |
public function setSMaxAge($smaxage) |
|
|
99 |
{ |
|
|
100 |
$this->smaxage = $smaxage; |
|
|
101 |
} |
|
|
102 |
|
|
|
103 |
/** |
|
|
104 |
* Returns the number of seconds the response is considered fresh by a |
|
|
105 |
* public cache. |
|
|
106 |
* |
|
|
107 |
* @return integer |
|
|
108 |
*/ |
|
|
109 |
public function getSMaxAge() |
|
|
110 |
{ |
|
|
111 |
return $this->smaxage; |
|
|
112 |
} |
|
|
113 |
|
|
|
114 |
/** |
|
|
115 |
* Returns whether or not a response is public. |
|
|
116 |
* |
|
|
117 |
* @return Boolean |
|
|
118 |
*/ |
|
|
119 |
public function isPublic() |
|
|
120 |
{ |
|
|
121 |
return (Boolean) $this->public; |
|
|
122 |
} |
|
|
123 |
|
|
|
124 |
/** |
|
|
125 |
* Sets a response public. |
|
|
126 |
* |
|
|
127 |
* @param Boolean $public A boolean value |
|
|
128 |
*/ |
|
|
129 |
public function setPublic($public) |
|
|
130 |
{ |
|
|
131 |
$this->public = (Boolean) $public; |
|
|
132 |
} |
|
|
133 |
|
|
|
134 |
/** |
|
|
135 |
* Returns the annotation alias name. |
|
|
136 |
* |
|
|
137 |
* @return string |
|
|
138 |
* @see ConfigurationInterface |
|
|
139 |
*/ |
|
|
140 |
public function getAliasName() |
|
|
141 |
{ |
|
|
142 |
return 'cache'; |
|
|
143 |
} |
|
|
144 |
} |