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