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