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