| @@ 115-134 (lines=20) @@ | ||
| 112 | $propertyMetadata->setValue($object, $data); |
|
| 113 | } |
|
| 114 | ||
| 115 | private function fetchBelongsToMulti( |
|
| 116 | $object, |
|
| 117 | string $type, |
|
| 118 | TransferMetadata $metadata, |
|
| 119 | PropertyMetadata $propertyMetadata, |
|
| 120 | BelongsTo $belongsTo, |
|
| 121 | TransferManagerInterface $transferManager |
|
| 122 | ||
| 123 | ) { |
|
| 124 | $criteria = []; |
|
| 125 | ||
| 126 | foreach ($belongsTo->foreignField as $field) { |
|
| 127 | $criteria[$field] = $metadata->propertyMetadata[$field]->getValue($object); |
|
| 128 | } |
|
| 129 | ||
| 130 | $data = $transferManager->getRepository($type) |
|
| 131 | ->findOneBy($criteria); |
|
| 132 | ||
| 133 | $propertyMetadata->setValue($object, $data); |
|
| 134 | } |
|
| 135 | ||
| 136 | private function fetchHasOne( |
|
| 137 | TransferMetadata $metadata, |
|
| @@ 103-114 (lines=12) @@ | ||
| 100 | } |
|
| 101 | } |
|
| 102 | ||
| 103 | private function persistBelongsTo($object, $association, TransferMetadata $metadata, PropertyMetadata $property) |
|
| 104 | { |
|
| 105 | /* @var $belongsTo BelongsTo */ |
|
| 106 | $belongsTo = $property->getAnnotation(BelongsTo::class); |
|
| 107 | $foreignProperty = $metadata->propertyMetadata[$belongsTo->foreignField]; |
|
| 108 | $foreignId = $foreignProperty->getValue($object); |
|
| 109 | $currentId = $this->getIdValue($association); |
|
| 110 | ||
| 111 | if ($foreignId !== $currentId) { |
|
| 112 | $foreignProperty->setValue($object, $currentId); |
|
| 113 | } |
|
| 114 | } |
|
| 115 | ||
| 116 | private function persistHas($object, $association, PropertyMetadata $property, $annotation) |
|
| 117 | { |
|