1: <?php
2:
3: namespace webfilesframework\io\form\webfile;
4: use webfilesframework\core\datasystem\file\format\MWebfile;
5:
6: 7: 8: 9: 10: 11: 12:
13: class MWebfileFormHandler
14: {
15:
16: var $requestArray;
17:
18: 19: 20:
21: public function __construct($requestArray)
22: {
23: $this->requestArray = $requestArray;
24: }
25:
26: 27: 28: 29:
30: public function getWebfileFromRequestArray()
31: {
32:
33: $lastPositionOfPoint = strrpos($this->requestArray['classname'], ".");
34: if ($lastPositionOfPoint != false) {
35: $lastPositionOfPoint++;
36: } else {
37: $lastPositionOfPoint = 0;
38: }
39:
40: $classnameWithoutPackagePath = substr($this->requestArray['classname'], $lastPositionOfPoint);
41:
42:
43: $item = new $classnameWithoutPackagePath;
44: $attributes = $item->getAttributes();
45:
46:
47: foreach ($attributes as $attribute) {
48: $attributeName = $attribute->getName();
49: if (isset($this->requestArray[$attributeName])) {
50: $attribute->setAccessible(true);
51: $attribute->setValue($item, $this->requestArray[$attributeName]);
52: }
53: }
54: return $item;
55: }
56:
57: }