|
@@ 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( |
|
@@ 151-188 (lines=38) @@
|
| 148 |
|
$mapping = $this->mappingDriver->loadRDMMetadataForClass($className); |
| 149 |
|
|
| 150 |
|
if ($mapping instanceof EntityMappingInterface) { |
| 151 |
|
if ($mapping instanceof EntityMappingInterface) { |
| 152 |
|
$context = new HydrationContext($entity, $entityManager); |
| 153 |
|
|
| 154 |
|
foreach ($mapping->getFieldMappings() as $fieldName => $fieldMapping) { |
| 155 |
|
/** @var MappingInterface $fieldMapping */ |
| 156 |
|
|
| 157 |
|
/** @var ReflectionClass $concreteClassReflection */ |
| 158 |
|
$concreteClassReflection = $classReflection; |
| 159 |
|
|
| 160 |
|
while (!$concreteClassReflection->hasProperty($fieldName)) { |
| 161 |
|
$concreteClassReflection = $concreteClassReflection->getParentClass(); |
| 162 |
|
|
| 163 |
|
Assert::notFalse($concreteClassReflection, sprintf( |
| 164 |
|
"Property '%s' does not exist on object of class '%s'!", |
| 165 |
|
$fieldName, |
| 166 |
|
$className |
| 167 |
|
)); |
| 168 |
|
} |
| 169 |
|
|
| 170 |
|
/** @var ReflectionProperty $propertyReflection */ |
| 171 |
|
$propertyReflection = $concreteClassReflection->getProperty($fieldName); |
| 172 |
|
|
| 173 |
|
$propertyReflection->setAccessible(true); |
| 174 |
|
|
| 175 |
|
/** @var object|null $actualValue */ |
| 176 |
|
$actualValue = null; |
| 177 |
|
|
| 178 |
|
if ($propertyReflection->isInitialized($entity)) { |
| 179 |
|
$actualValue = $propertyReflection->getValue($entity); |
| 180 |
|
} |
| 181 |
|
|
| 182 |
|
$fieldMapping->assertValue( |
| 183 |
|
$context, |
| 184 |
|
$dataFromAdditionalColumns, |
| 185 |
|
$actualValue |
| 186 |
|
); |
| 187 |
|
} |
| 188 |
|
} |
| 189 |
|
} |
| 190 |
|
|
| 191 |
|
$className = current(class_parents($className)); |