/lib/ezc/MvcTools/src/structs/request.php

https://bitbucket.org/crevillo/enetcall · PHP · 209 lines · 49 code · 17 blank · 143 comment · 0 complexity · 9989ffd547a8993f078dae61365bb395 MD5 · raw file

  1. <?php
  2. /**
  3. * File containing the ezcMvcRequest class
  4. *
  5. * @copyright Copyright (C) 2005-2010 eZ Systems AS. All rights reserved.
  6. * @license http://ez.no/licenses/new_bsd New BSD License
  7. * @version //autogentag//
  8. * @filesource
  9. * @package MvcTools
  10. */
  11. /**
  12. * The request object holds the request data.
  13. *
  14. * The request object should be created by the request parser
  15. * in the first place.
  16. * It may also be returned by the controller, in the case of an
  17. * internal redirection.
  18. *
  19. * It holds the protocol dependant data in an ezcMvcRawRequest
  20. * object that is held in property $raw.
  21. *
  22. * It holds several structs which contain some protocol abstract
  23. * data in the following properties:
  24. * - $files: array of instances of ezcMvcRequestFile.
  25. * - $cache: instance of ezcMvcRequestCache
  26. * - $content: instance of ezcMvcRequestContent
  27. * - $agent: instance of ezcMvcRequestAgent
  28. * - $authentication: instance of ezcMvcRequestAuthentication
  29. *
  30. * It holds request variables like an array. For example, to hold
  31. * a 'controller' GET variable in $request['controller'].
  32. *
  33. * @package MvcTools
  34. * @version //autogentag//
  35. */
  36. class ezcMvcRequest extends ezcBaseStruct
  37. {
  38. /**
  39. * Date of the request
  40. *
  41. * @var DateTime
  42. */
  43. public $date;
  44. /**
  45. * Protocol description in a normalized form
  46. * F.e. http-get, http-post, http-delete, mail, jabber
  47. *
  48. * @var string
  49. */
  50. public $protocol;
  51. /**
  52. * Hostname of the requested server
  53. *
  54. * @var string
  55. */
  56. public $host;
  57. /**
  58. * Uri of the requested resource
  59. *
  60. * @var string
  61. */
  62. public $uri;
  63. /**
  64. * Full Uri - combination of host name and uri in a protocol independent
  65. * order
  66. *
  67. * @var string
  68. */
  69. public $requestId;
  70. /**
  71. * Request ID of the referring URI in the same format as $requestId
  72. *
  73. * @var string
  74. */
  75. public $referrer;
  76. /**
  77. * Request variables.
  78. *
  79. * @var array
  80. */
  81. public $variables;
  82. /**
  83. * Request body.
  84. *
  85. * @var string
  86. */
  87. public $body;
  88. /**
  89. * Files bundled with the request.
  90. *
  91. * @var array(ezcMvcRequestFile)
  92. */
  93. public $files;
  94. /**
  95. * Request content type informations.
  96. *
  97. * @var ezcMvcRequestAccept
  98. */
  99. public $accept;
  100. /**
  101. * Request user agent informations.
  102. *
  103. * @var ezcMvcRequestUserAgent
  104. */
  105. public $agent;
  106. /**
  107. * Request authentication data.
  108. *
  109. * @var ezcMvcRequestAuthentication
  110. */
  111. public $authentication;
  112. /**
  113. * Raw request data
  114. *
  115. * @var ezcMvcRawRequest
  116. */
  117. public $raw;
  118. /**
  119. * Contains all the cookies to be set
  120. *
  121. * @var array(ezcMvcRequestCookie)
  122. */
  123. public $cookies;
  124. /**
  125. * Whether this is a fatal error request, or a normal one
  126. *
  127. * @var boolean
  128. */
  129. public $isFatal;
  130. /**
  131. * Constructs a new ezcMvcRequest.
  132. *
  133. * @param DateTime $date
  134. * @param string $protocol
  135. * @param string $host
  136. * @param string $uri
  137. * @param string $requestId
  138. * @param string $referrer
  139. * @param array $variables
  140. * @param string $body
  141. * @param array(ezcMvcRequestFile) $files
  142. * @param ezcMvcRequestAccept $accept
  143. * @param ezcMvcRequestUserAgent $agent
  144. * @param ezcMvcRequestAuthentication $authentication
  145. * @param ezcMvcRawRequest $raw
  146. * @param array(ezcMvcRequestCookie) $cookies
  147. * @param bool $isFatal
  148. */
  149. public function __construct( $date = null, $protocol = '',
  150. $host = '', $uri = '', $requestId = '', $referrer = '',
  151. $variables = array(), $body = '', $files = null, $accept = null,
  152. $agent = null, $authentication = null, $raw = null, $cookies = array(), $isFatal = false )
  153. {
  154. $this->date = $date;
  155. $this->protocol = $protocol;
  156. $this->host = $host;
  157. $this->uri = $uri;
  158. $this->requestId = $requestId;
  159. $this->referrer = $referrer;
  160. $this->variables = $variables;
  161. $this->body = $body;
  162. $this->files = $files;
  163. $this->accept = $accept;
  164. $this->agent = $agent;
  165. $this->authentication = $authentication;
  166. $this->raw = $raw;
  167. $this->cookies = $cookies;
  168. }
  169. /**
  170. * Returns a new instance of this class with the data specified by $array.
  171. *
  172. * $array contains all the data members of this class in the form:
  173. * array('member_name'=>value).
  174. *
  175. * __set_state makes this class exportable with var_export.
  176. * var_export() generates code, that calls this method when it
  177. * is parsed with PHP.
  178. *
  179. * @param array(string=>mixed) $array
  180. * @return ezcMvcRequest
  181. */
  182. static public function __set_state( array $array )
  183. {
  184. return new ezcMvcRequest( $array['date'], $array['protocol'],
  185. $array['host'], $array['uri'], $array['requestId'],
  186. $array['referrer'], $array['variables'], $array['body'],
  187. $array['files'], $array['accept'], $array['agent'],
  188. $array['authentication'], $array['raw'], $array['cookies'],
  189. $array['isFatal'] );
  190. }
  191. }
  192. ?>