Cache.php 2.9KB

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