| Conditions | 5 |
| Paths | 4 |
| Total Lines | 23 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 38 | public function handleManyRelationType($class, $data, $dataField, $config, $dbField) |
||
| 39 | { |
||
| 40 | if (!array_key_exists('relation', $config) || !is_array($config['relation'])) { |
||
| 41 | return []; |
||
| 42 | } |
||
| 43 | |||
| 44 | $fieldData = $data[$dataField]; |
||
| 45 | $related = []; |
||
| 46 | |||
| 47 | foreach ($this->owner->yieldSingle($fieldData) as $entry) { |
||
| 48 | $entryData = array_merge($data, [ |
||
| 49 | $dataField => $entry, |
||
| 50 | ]); |
||
| 51 | |||
| 52 | if (is_array($entry)) { |
||
| 53 | $entryData = array_merge($entryData, $entry); |
||
| 54 | } |
||
| 55 | |||
| 56 | $relationConfig = $config['relation']; |
||
| 57 | $relatedClass = array_key_first($relationConfig); |
||
| 58 | $related[] = $this->owner->mapToObject($relatedClass, $relationConfig[$relatedClass], $entryData); |
||
| 59 | } |
||
| 60 | return $related; |
||
| 61 | } |
||
| 63 |