1: <?php
2:
3: /**
4: * This file is part of the Nette Framework (http://nette.org)
5: *
6: * Copyright (c) 2004, 2011 David Grudl (http://davidgrudl.com)
7: *
8: * For the full copyright and license information, please view
9: * the file license.txt that was distributed with this source code.
10: * @package Nette\Application
11: */
12:
13:
14:
15: /**
16: * Redirects to new URI.
17: *
18: * @author David Grudl
19: */
20: class RedirectingResponse extends Object implements IPresenterResponse
21: {
22: /** @var string */
23: private $uri;
24:
25: /** @var int */
26: private $code;
27:
28:
29:
30: /**
31: * @param string URI
32: * @param int HTTP code 3xx
33: */
34: public function __construct($uri, $code = IHttpResponse::S302_FOUND)
35: {
36: $this->uri = (string) $uri;
37: $this->code = (int) $code;
38: }
39:
40:
41:
42: /**
43: * @return string
44: */
45: final public function getUri()
46: {
47: return $this->uri;
48: }
49:
50:
51:
52: /**
53: * @return int
54: */
55: final public function getCode()
56: {
57: return $this->code;
58: }
59:
60:
61:
62: /**
63: * Sends response to output.
64: * @return void
65: */
66: public function send(IHttpRequest $httpRequest, IHttpResponse $httpResponse)
67: {
68: $httpResponse->redirect($this->uri, $this->code);
69: }
70:
71: }
72: