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: public function __construct($name, $method, array $params, array $post = array(), array $files = array(), array $flags = array())
68: {
69: $this->name = $name;
70: $this->method = $method;
71: $this->params = $params;
72: $this->post = $post;
73: $this->files = $files;
74: $this->flags = $flags;
75: }
76:
77:
78:
79: 80: 81: 82: 83:
84: public function setPresenterName($name)
85: {
86: $this->updating();
87: $this->name = $name;
88: return $this;
89: }
90:
91:
92:
93: 94: 95: 96:
97: public function getPresenterName()
98: {
99: return $this->name;
100: }
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:
152: public function setPost(array $params)
153: {
154: $this->updating();
155: $this->post = $params;
156: return $this;
157: }
158:
159:
160:
161: 162: 163: 164:
165: public function getPost()
166: {
167: return $this->post;
168: }
169:
170:
171:
172: 173: 174: 175: 176:
177: public function setFiles(array $files)
178: {
179: $this->updating();
180: $this->files = $files;
181: return $this;
182: }
183:
184:
185:
186: 187: 188: 189:
190: public function getFiles()
191: {
192: return $this->files;
193: }
194:
195:
196:
197: 198: 199: 200: 201:
202: public function setMethod($method)
203: {
204: $this->method = $method;
205: return $this;
206: }
207:
208:
209:
210: 211: 212: 213:
214: public function getMethod()
215: {
216: return $this->method;
217: }
218:
219:
220:
221: 222: 223: 224: 225:
226: public function isMethod($method)
227: {
228: return strcasecmp($this->method, $method) === 0;
229: }
230:
231:
232:
233: 234: 235: 236:
237: public function isPost()
238: {
239: return strcasecmp($this->method, 'post') === 0;
240: }
241:
242:
243:
244: 245: 246: 247: 248: 249:
250: public function setFlag($flag, $value = TRUE)
251: {
252: $this->updating();
253: $this->flags[$flag] = (bool) $value;
254: return $this;
255: }
256:
257:
258:
259: 260: 261: 262: 263:
264: public function hasFlag($flag)
265: {
266: return !empty($this->flags[$flag]);
267: }
268:
269: }
270: