1: <?php
2:
3: /**
4: * This file is part of the Nette Framework.
5: *
6: * Copyright (c) 2004, 2010 David Grudl (http://davidgrudl.com)
7: *
8: * This source file is subject to the "Nette license", and/or
9: * GPL license. For more information please see http://nette.org
10: * @package Nette\Application
11: */
12:
13:
14:
15: /**
16: * Redirects to new request.
17: *
18: * @author David Grudl
19: */
20: class RedirectingResponse extends Object implements IPresenterResponse
21: {
22: /** @var string */
23: private $uri;
24:
25: /** @var int */
26: private $code;
27:
28:
29:
30: /**
31: * @param string URI
32: * @param int HTTP code 3xx
33: */
34: public function __construct($uri, $code = IHttpResponse::S302_FOUND)
35: {
36: $this->uri = (string) $uri;
37: $this->code = (int) $code;
38: }
39:
40:
41:
42: /**
43: * @return string
44: */
45: final public function getUri()
46: {
47: return $this->uri;
48: }
49:
50:
51:
52: /**
53: * @return int
54: */
55: final public function getCode()
56: {
57: return $this->code;
58: }
59:
60:
61:
62: /**
63: * Sends response to output.
64: * @return void
65: */
66: public function send()
67: {
68: Environment::getHttpResponse()->redirect($this->uri, $this->code);
69: }
70:
71: }
72: