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