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:
110: public function setParameters(array $params)
111: {
112: $this->updating();
113: $this->params = $params;
114: return $this;
115: }
116:
117:
118:
119: 120: 121: 122:
123: public function getParameters()
124: {
125: return $this->params;
126: }
127:
128:
129:
130:
131: function setParams(array $params)
132: {
133: trigger_error(__METHOD__ . '() is deprecated; use setParameters() instead.', E_USER_WARNING);
134: return $this->setParameters($params);
135: }
136:
137:
138:
139:
140: function getParams()
141: {
142: trigger_error(__METHOD__ . '() is deprecated; use getParameters() instead.', E_USER_WARNING);
143: return $this->getParameters();
144: }
145:
146:
147:
148: 149: 150: 151: 152:
153: public function setPost(array $params)
154: {
155: $this->updating();
156: $this->post = $params;
157: return $this;
158: }
159:
160:
161:
162: 163: 164: 165:
166: public function getPost()
167: {
168: return $this->post;
169: }
170:
171:
172:
173: 174: 175: 176: 177:
178: public function setFiles(array $files)
179: {
180: $this->updating();
181: $this->files = $files;
182: return $this;
183: }
184:
185:
186:
187: 188: 189: 190:
191: public function getFiles()
192: {
193: return $this->files;
194: }
195:
196:
197:
198: 199: 200: 201: 202:
203: public function setMethod($method)
204: {
205: $this->method = $method;
206: return $this;
207: }
208:
209:
210:
211: 212: 213: 214:
215: public function getMethod()
216: {
217: return $this->method;
218: }
219:
220:
221:
222: 223: 224: 225: 226:
227: public function isMethod($method)
228: {
229: return strcasecmp($this->method, $method) === 0;
230: }
231:
232:
233:
234: 235: 236: 237:
238: public function isPost()
239: {
240: return strcasecmp($this->method, 'post') === 0;
241: }
242:
243:
244:
245: 246: 247: 248: 249: 250:
251: public function setFlag($flag, $value = TRUE)
252: {
253: $this->updating();
254: $this->flags[$flag] = (bool) $value;
255: return $this;
256: }
257:
258:
259:
260: 261: 262: 263: 264:
265: public function hasFlag($flag)
266: {
267: return !empty($this->flags[$flag]);
268: }
269:
270: }
271: