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