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: * @param string URI
35: * @param int HTTP code 3xx
36: */
37: public function __construct($url, $code = IHttpResponse::S302_FOUND)
38: {
39: $this->url = (string) $url;
40: $this->code = (int) $code;
41: }
42:
43:
44: /**
45: * @return string
46: */
47: final public function getUrl()
48: {
49: return $this->url;
50: }
51:
52:
53: /**
54: * @return int
55: */
56: final public function getCode()
57: {
58: return $this->code;
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->url, $this->code);
69: }
70:
71: }
72: