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