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