1: <?php
2:
3: 4: 5: 6: 7:
8:
9:
10:
11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22:
23: class PresenterRequest extends FreezableObject
24: {
25:
26: const FORWARD = 'FORWARD';
27:
28:
29: const SECURED = 'secured';
30:
31:
32: const RESTORED = 'restored';
33:
34:
35: private $method;
36:
37:
38: private $flags = array();
39:
40:
41: private $name;
42:
43:
44: private $params;
45:
46:
47: private $post;
48:
49:
50: private $files;
51:
52:
53: 54: 55: 56: 57: 58: 59: 60:
61: public function __construct($name, $method, array $params, array $post = array(), array $files = array(), array $flags = array())
62: {
63: $this->name = $name;
64: $this->method = $method;
65: $this->params = $params;
66: $this->post = $post;
67: $this->files = $files;
68: $this->flags = $flags;
69: }
70:
71:
72: 73: 74: 75: 76:
77: public function setPresenterName($name)
78: {
79: $this->updating();
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->updating();
102: $this->params = $params;
103: return $this;
104: }
105:
106:
107: 108: 109: 110:
111: public function getParameters()
112: {
113: return $this->params;
114: }
115:
116:
117:
118: function setParams(array $params)
119: {
120: trigger_error(__METHOD__ . '() is deprecated; use setParameters() instead.', E_USER_WARNING);
121: return $this->setParameters($params);
122: }
123:
124:
125:
126: function getParams()
127: {
128: trigger_error(__METHOD__ . '() is deprecated; use getParameters() instead.', E_USER_WARNING);
129: return $this->getParameters();
130: }
131:
132:
133: 134: 135: 136:
137: public function setPost(array $params)
138: {
139: $this->updating();
140: $this->post = $params;
141: return $this;
142: }
143:
144:
145: 146: 147: 148:
149: public function getPost()
150: {
151: return $this->post;
152: }
153:
154:
155: 156: 157: 158:
159: public function setFiles(array $files)
160: {
161: $this->updating();
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:
214: public function isPost()
215: {
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->updating();
229: $this->flags[$flag] = (bool) $value;
230: return $this;
231: }
232:
233:
234: 235: 236: 237: 238:
239: public function hasFlag($flag)
240: {
241: return !empty($this->flags[$flag]);
242: }
243:
244: }
245: