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