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