1: <?php
2:
3: 4: 5: 6:
7:
8: namespace Nette\Application;
9:
10: use Nette;
11:
12:
13: 14: 15: 16: 17: 18: 19: 20:
21: class Request extends Nette\Object
22: {
23:
24: const FORWARD = 'FORWARD';
25:
26:
27: const SECURED = 'secured';
28:
29:
30: const RESTORED = 'restored';
31:
32:
33: private $method;
34:
35:
36: private $flags = array();
37:
38:
39: private $name;
40:
41:
42: private $params;
43:
44:
45: private $post;
46:
47:
48: private $files;
49:
50:
51: 52: 53: 54: 55: 56: 57: 58:
59: public function __construct($name, $method = NULL, array $params = array(), array $post = array(), array $files = array(), array $flags = array())
60: {
61: $this->name = $name;
62: $this->method = $method;
63: $this->params = $params;
64: $this->post = $post;
65: $this->files = $files;
66: $this->flags = $flags;
67: }
68:
69:
70: 71: 72: 73: 74:
75: public function setPresenterName($name)
76: {
77: $this->name = $name;
78: return $this;
79: }
80:
81:
82: 83: 84: 85:
86: public function getPresenterName()
87: {
88: return $this->name;
89: }
90:
91:
92: 93: 94: 95:
96: public function setParameters(array $params)
97: {
98: $this->params = $params;
99: return $this;
100: }
101:
102:
103: 104: 105: 106:
107: public function getParameters()
108: {
109: return $this->params;
110: }
111:
112:
113: 114: 115: 116: 117:
118: public function getParameter($key)
119: {
120: return isset($this->params[$key]) ? $this->params[$key] : NULL;
121: }
122:
123:
124: 125: 126: 127:
128: public function setPost(array $params)
129: {
130: $this->post = $params;
131: return $this;
132: }
133:
134:
135: 136: 137: 138: 139: 140:
141: public function getPost($key = NULL)
142: {
143: if (func_num_args() === 0) {
144: return $this->post;
145:
146: } elseif (isset($this->post[$key])) {
147: return $this->post[$key];
148:
149: } else {
150: return NULL;
151: }
152: }
153:
154:
155: 156: 157: 158:
159: public function setFiles(array $files)
160: {
161: $this->files = $files;
162: return $this;
163: }
164:
165:
166: 167: 168: 169:
170: public function getFiles()
171: {
172: return $this->files;
173: }
174:
175:
176: 177: 178: 179: 180:
181: public function setMethod($method)
182: {
183: $this->method = $method;
184: return $this;
185: }
186:
187:
188: 189: 190: 191:
192: public function getMethod()
193: {
194: return $this->method;
195: }
196:
197:
198: 199: 200: 201: 202:
203: public function isMethod($method)
204: {
205: return strcasecmp($this->method, $method) === 0;
206: }
207:
208:
209: 210: 211:
212: public function isPost()
213: {
214: trigger_error('Method isPost() is deprecated, use isMethod(\'POST\') instead.', E_USER_DEPRECATED);
215: return strcasecmp($this->method, 'post') === 0;
216: }
217:
218:
219: 220: 221: 222: 223: 224:
225: public function setFlag($flag, $value = TRUE)
226: {
227: $this->flags[$flag] = (bool) $value;
228: return $this;
229: }
230:
231:
232: 233: 234: 235: 236:
237: public function hasFlag($flag)
238: {
239: return !empty($this->flags[$flag]);
240: }
241:
242: }
243: