@@ 76-113 (lines=38) @@ | ||
73 | $processDescription = sprintf("of entity '%s'", $className); |
|
74 | ||
75 | try { |
|
76 | if ($mapping instanceof EntityMappingInterface) { |
|
77 | $context = new HydrationContext($entity, $entityManager); |
|
78 | ||
79 | foreach ($mapping->getFieldMappings() as $fieldName => $fieldMapping) { |
|
80 | /** @var MappingInterface $fieldMapping */ |
|
81 | ||
82 | $processDescription = sprintf( |
|
83 | "of field '%s' of entity '%s'", |
|
84 | $fieldName, |
|
85 | $className |
|
86 | ); |
|
87 | ||
88 | /** @var mixed $value */ |
|
89 | $value = $fieldMapping->resolveValue( |
|
90 | $context, |
|
91 | $dataFromAdditionalColumns |
|
92 | ); |
|
93 | ||
94 | /** @var ReflectionClass $concreteClassReflection */ |
|
95 | $concreteClassReflection = $classReflection; |
|
96 | ||
97 | while (!$concreteClassReflection->hasProperty($fieldName)) { |
|
98 | $concreteClassReflection = $concreteClassReflection->getParentClass(); |
|
99 | ||
100 | Assert::object($concreteClassReflection, sprintf( |
|
101 | "Property '%s' does not exist on object of class '%s'!", |
|
102 | $fieldName, |
|
103 | $className |
|
104 | )); |
|
105 | } |
|
106 | ||
107 | /** @var ReflectionProperty $propertyReflection */ |
|
108 | $propertyReflection = $concreteClassReflection->getProperty($fieldName); |
|
109 | ||
110 | $propertyReflection->setAccessible(true); |
|
111 | $propertyReflection->setValue($entity, $value); |
|
112 | } |
|
113 | } |
|
114 | ||
115 | } catch (Throwable $exception) { |
|
116 | throw new MappingException(sprintf( |
|
@@ 149-184 (lines=36) @@ | ||
146 | /** @var ?EntityMappingInterface $mapping */ |
|
147 | $mapping = $this->mappingDriver->loadRDMMetadataForClass($className); |
|
148 | ||
149 | if ($mapping instanceof EntityMappingInterface) { |
|
150 | if ($mapping instanceof EntityMappingInterface) { |
|
151 | $context = new HydrationContext($entity, $entityManager); |
|
152 | ||
153 | foreach ($mapping->getFieldMappings() as $fieldName => $fieldMapping) { |
|
154 | /** @var MappingInterface $fieldMapping */ |
|
155 | ||
156 | /** @var ReflectionClass $concreteClassReflection */ |
|
157 | $concreteClassReflection = $classReflection; |
|
158 | ||
159 | while (!$concreteClassReflection->hasProperty($fieldName)) { |
|
160 | $concreteClassReflection = $concreteClassReflection->getParentClass(); |
|
161 | ||
162 | Assert::notFalse($concreteClassReflection, sprintf( |
|
163 | "Property '%s' does not exist on object of class '%s'!", |
|
164 | $fieldName, |
|
165 | $className |
|
166 | )); |
|
167 | } |
|
168 | ||
169 | /** @var ReflectionProperty $propertyReflection */ |
|
170 | $propertyReflection = $concreteClassReflection->getProperty($fieldName); |
|
171 | ||
172 | $propertyReflection->setAccessible(true); |
|
173 | ||
174 | /** @var object $actualValue */ |
|
175 | $actualValue = $propertyReflection->getValue($entity); |
|
176 | ||
177 | $fieldMapping->assertValue( |
|
178 | $context, |
|
179 | $dataFromAdditionalColumns, |
|
180 | $actualValue |
|
181 | ); |
|
182 | } |
|
183 | } |
|
184 | } |
|
185 | ||
186 | $className = current(class_parents($className)); |
|
187 | } while (class_exists($className)); |