1 | <?php |
||
48 | class Response |
||
49 | { |
||
50 | /** |
||
51 | * @access protected |
||
52 | * @var RequestAbstract |
||
53 | */ |
||
54 | protected $request; |
||
55 | |||
56 | /** |
||
57 | * @access protected |
||
58 | * @var array |
||
59 | */ |
||
60 | protected $data = array(); |
||
61 | |||
62 | /** |
||
63 | * @access protected |
||
64 | * @var array |
||
65 | */ |
||
66 | protected $outputParts = array(); |
||
67 | |||
68 | /** |
||
69 | * @access protected |
||
70 | * @var string |
||
71 | */ |
||
72 | protected $output; |
||
73 | |||
74 | /** |
||
75 | * @var boolean |
||
76 | */ |
||
77 | protected $outputLocked = false; |
||
78 | |||
79 | /** |
||
80 | * Constructs the object |
||
81 | * |
||
82 | * @access public |
||
83 | * @param \Zepi\Turbo\Request\RequestAbstract $request |
||
84 | */ |
||
85 | 25 | public function __construct(RequestAbstract $request) |
|
89 | |||
90 | /** |
||
91 | * Return the data for the given key. If the key does |
||
92 | * not exists the function will return false. |
||
93 | * |
||
94 | * @access public |
||
95 | * @param string $key |
||
96 | * @return mixed |
||
97 | */ |
||
98 | 4 | public function getData($key) |
|
106 | |||
107 | /** |
||
108 | * Returns true if the given key is set. |
||
109 | * |
||
110 | * @access public |
||
111 | * @param string $key |
||
112 | * @return boolean |
||
113 | */ |
||
114 | 4 | public function hasData($key) |
|
118 | |||
119 | /** |
||
120 | * Saves the value for the given key in the response object. |
||
121 | * |
||
122 | * @access public |
||
123 | * @param string $key |
||
124 | * @param mixed $value |
||
125 | */ |
||
126 | 3 | public function setData($key, $value) |
|
130 | |||
131 | /** |
||
132 | * Returns the output for the given key. If the key does |
||
133 | * not exists the function will return false. |
||
134 | * |
||
135 | * @access public |
||
136 | * @param string $key |
||
137 | * @return false|string |
||
138 | */ |
||
139 | 2 | public function getOutputPart($key) |
|
147 | |||
148 | /** |
||
149 | * Returns true if the given key exists as output key. |
||
150 | * |
||
151 | * @access public |
||
152 | * @param string $key |
||
153 | * @return boolean |
||
154 | */ |
||
155 | 2 | public function hasOutputPart($key) |
|
159 | |||
160 | /** |
||
161 | * Saves the output for the given key in the Response object. |
||
162 | * |
||
163 | * @access public |
||
164 | * @param string $key |
||
165 | * @param string $output |
||
166 | */ |
||
167 | 2 | public function setOutputPart($key, $output) |
|
171 | |||
172 | /** |
||
173 | * Returns all output parts of the Response object. |
||
174 | * |
||
175 | * @access public |
||
176 | * @return array |
||
177 | */ |
||
178 | 1 | public function getOutputParts() |
|
182 | |||
183 | /** |
||
184 | * Returns the output of the response. |
||
185 | * |
||
186 | * @access public |
||
187 | * @return string |
||
188 | */ |
||
189 | 3 | public function getOutput() |
|
193 | |||
194 | /** |
||
195 | * Returns true if the response has an output. |
||
196 | * |
||
197 | * @access public |
||
198 | * @return boolean |
||
199 | */ |
||
200 | 1 | public function hasOutput() |
|
204 | |||
205 | /** |
||
206 | * Sets the output of the response. |
||
207 | * If $lock is true the output will be locked and the method |
||
208 | * will not accept any other output. |
||
209 | * |
||
210 | * @access public |
||
211 | * @param string $output |
||
212 | * @param boolean $lock |
||
213 | * @return boolean |
||
214 | */ |
||
215 | 1 | public function setOutput($output, $lock = false) |
|
228 | |||
229 | /** |
||
230 | * Returns true if the output in the response is locked. |
||
231 | * |
||
232 | * @return boolean |
||
233 | */ |
||
234 | public function isOutputLocked() |
||
238 | |||
239 | /** |
||
240 | * Set the Location header to redirect a request |
||
241 | * |
||
242 | * @access public |
||
243 | * @param string $target |
||
244 | * @param integer $headerCode |
||
245 | * @param boolean $withOrigin |
||
246 | */ |
||
247 | 2 | public function redirectTo($target, $headerCode = 301, $withOrigin = false) |
|
263 | |||
264 | /** |
||
265 | * Sends a header |
||
266 | * |
||
267 | * @access public |
||
268 | * @param string $message |
||
269 | * @param integer $code |
||
270 | */ |
||
271 | public function sendHeader($message, $code = null) |
||
283 | |||
284 | /** |
||
285 | * Sends the status code for the give code |
||
286 | * |
||
287 | * @access public |
||
288 | * @param integer $code |
||
289 | * @param boolean $resetOutput |
||
290 | */ |
||
291 | public function sendHttpStatus($code, $resetOutput = false) |
||
366 | |||
367 | /** |
||
368 | * Returns a full url for the given url parts array |
||
369 | * from the function `parse_url()`. |
||
370 | * |
||
371 | * @access public |
||
372 | * @param array $urlParts |
||
373 | * @return string |
||
374 | */ |
||
375 | public function buildUrl($urlParts) |
||
379 | |||
380 | /** |
||
381 | * Adds the origin and returns the given target url |
||
382 | * with the origin query parameter. |
||
383 | * |
||
384 | * @param string $target |
||
385 | * @return void|string |
||
386 | */ |
||
387 | protected function addOriginToTargetUrl($target) |
||
407 | } |
||
408 |