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: * @package Nette\Application
11: */
12:
13:
14:
15: /**
16: * Redirects to new request.
17: *
18: * @author David Grudl
19: * @package Nette\Application
20: */
21: class NRedirectingResponse extends NObject implements IPresenterResponse
22: {
23: /** @var string */
24: private $uri;
25:
26: /** @var int */
27: private $code;
28:
29:
30:
31: /**
32: * @param string URI
33: * @param int HTTP code 3xx
34: */
35: public function __construct($uri, $code = IHttpResponse::S302_FOUND)
36: {
37: $this->uri = (string) $uri;
38: $this->code = (int) $code;
39: }
40:
41:
42:
43: /**
44: * @return string
45: */
46: final public function getUri()
47: {
48: return $this->uri;
49: }
50:
51:
52:
53: /**
54: * @return int
55: */
56: final public function getCode()
57: {
58: return $this->code;
59: }
60:
61:
62:
63: /**
64: * Sends response to output.
65: * @return void
66: */
67: public function send()
68: {
69: NEnvironment::getHttpResponse()->redirect($this->uri, $this->code);
70: }
71:
72: }
73: