1: <?php
2:
3: /**
4: * This file is part of the Nette Framework (https://nette.org)
5: *
6: * Copyright (c) 2004 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: */
11:
12: namespace Nette\Application;
13:
14: use Nette;
15:
16:
17:
18: /**
19: * Redirects to new request.
20: *
21: * @author David Grudl
22: */
23: class RedirectingResponse extends Nette\Object implements IPresenterResponse
24: {
25: /** @var string */
26: private $uri;
27:
28: /** @var int */
29: private $code;
30:
31:
32:
33: /**
34: * @param string URI
35: * @param int HTTP code 3xx
36: */
37: public function __construct($uri, $code = Nette\Web\IHttpResponse::S302_FOUND)
38: {
39: $this->uri = (string) $uri;
40: $this->code = (int) $code;
41: }
42:
43:
44:
45: /**
46: * @return string
47: */
48: final public function getUri()
49: {
50: return $this->uri;
51: }
52:
53:
54:
55: /**
56: * @return int
57: */
58: final public function getCode()
59: {
60: return $this->code;
61: }
62:
63:
64:
65: /**
66: * Sends response to output.
67: * @return void
68: */
69: public function send()
70: {
71: Nette\Environment::getHttpResponse()->redirect($this->uri, $this->code);
72: }
73:
74: }
75: