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\FreezableObject
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, array $params, 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->updating();
81: $this->name = $name;
82: return $this;
83: }
84:
85:
86: 87: 88: 89:
90: public function getPresenterName()
91: {
92: return $this->name;
93: }
94:
95:
96: 97: 98: 99:
100: public function setParameters(array $params)
101: {
102: $this->updating();
103: $this->params = $params;
104: return $this;
105: }
106:
107:
108: 109: 110: 111:
112: public function getParameters()
113: {
114: return $this->params;
115: }
116:
117:
118:
119: function setParams(array $params)
120: {
121: trigger_error(__METHOD__ . '() is deprecated; use setParameters() instead.', E_USER_WARNING);
122: return $this->setParameters($params);
123: }
124:
125:
126:
127: function getParams()
128: {
129: trigger_error(__METHOD__ . '() is deprecated; use getParameters() instead.', E_USER_WARNING);
130: return $this->getParameters();
131: }
132:
133:
134: 135: 136: 137:
138: public function setPost(array $params)
139: {
140: $this->updating();
141: $this->post = $params;
142: return $this;
143: }
144:
145:
146: 147: 148: 149:
150: public function getPost()
151: {
152: return $this->post;
153: }
154:
155:
156: 157: 158: 159:
160: public function setFiles(array $files)
161: {
162: $this->updating();
163: $this->files = $files;
164: return $this;
165: }
166:
167:
168: 169: 170: 171:
172: public function getFiles()
173: {
174: return $this->files;
175: }
176:
177:
178: 179: 180: 181: 182:
183: public function setMethod($method)
184: {
185: $this->method = $method;
186: return $this;
187: }
188:
189:
190: 191: 192: 193:
194: public function getMethod()
195: {
196: return $this->method;
197: }
198:
199:
200: 201: 202: 203: 204:
205: public function isMethod($method)
206: {
207: return strcasecmp($this->method, $method) === 0;
208: }
209:
210:
211: 212: 213: 214:
215: public function isPost()
216: {
217: return strcasecmp($this->method, 'post') === 0;
218: }
219:
220:
221: 222: 223: 224: 225: 226:
227: public function setFlag($flag, $value = TRUE)
228: {
229: $this->updating();
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: