Conditions | 3 |
Paths | 3 |
Total Lines | 18 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
36 | public function onBeforeWrite() |
||
37 | { |
||
38 | // Fields are declared in a config static on decorated models |
||
39 | $fieldMap = $this->getOwner()->config()->get('jsontext_field_map'); |
||
40 | $postVars = Controller::curr()->getRequest()->postVars(); |
||
41 | $data = []; |
||
42 | |||
43 | foreach ($fieldMap as $dbFieldName => $inputFields) { |
||
44 | foreach ($inputFields as $inputField) { |
||
45 | $data[$dbFieldName][] = [$inputField => $postVars[$inputField]]; |
||
46 | } |
||
47 | |||
48 | $jsonTextField = $this->getOwner()->dbObject($dbFieldName); |
||
49 | $this->getOwner()->setField($dbFieldName, $jsonTextField->toJSON($data[$dbFieldName])); |
||
50 | } |
||
51 | |||
52 | parent::onBeforeWrite(); |
||
53 | } |
||
54 | |||
56 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.