|
|
@ -42,10 +42,27 @@ class Data2DtoConverter |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$preparedPropertyType = $propertyType; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (interface_exists($preparedPropertyType)) { |
|
|
|
|
|
|
|
$attributedPropertyClass = $this->grabPropertyDTOClass($property); |
|
|
|
|
|
|
|
// Если не указали мета информацию для интерфейса - пропустим |
|
|
|
|
|
|
|
if (!$attributedPropertyClass) { |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Если класс не реализует интерфейс свойства - пропустим |
|
|
|
|
|
|
|
$interfaces = class_implements($attributedPropertyClass); |
|
|
|
|
|
|
|
if (!isset($interfaces[$preparedPropertyType])) { |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$preparedPropertyType = $attributedPropertyClass; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Если это class, то рекурсивно заполняем дальше |
|
|
|
// Если это class, то рекурсивно заполняем дальше |
|
|
|
if (class_exists($propertyType)) { |
|
|
|
if (class_exists($preparedPropertyType)) { |
|
|
|
$value = $this->convert($value, $propertyType); |
|
|
|
$value = $this->convert($value, $preparedPropertyType); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// присваиваем получившееся значение |
|
|
|
// присваиваем получившееся значение |
|
|
|
$property->setValue($object, $value); |
|
|
|
$property->setValue($object, $value); |
|
|
|
} |
|
|
|
} |
|
|
@ -109,13 +126,7 @@ class Data2DtoConverter |
|
|
|
|
|
|
|
|
|
|
|
private function transformArray(&$value, \ReflectionProperty $property): bool |
|
|
|
private function transformArray(&$value, \ReflectionProperty $property): bool |
|
|
|
{ |
|
|
|
{ |
|
|
|
$attributedPropertyClass = null; |
|
|
|
$attributedPropertyClass = $this->grabPropertyDTOClass($property); |
|
|
|
$propertyName = $property->getName(); |
|
|
|
|
|
|
|
$propertyExtractor = new PropertyExtractor($property->class, $propertyName); |
|
|
|
|
|
|
|
/** @var DTOMeta $dtoMeta */ |
|
|
|
|
|
|
|
if ($dtoMeta = $propertyExtractor->fetch(DTOMeta::class)) { |
|
|
|
|
|
|
|
$attributedPropertyClass = $dtoMeta->class; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @var \ReflectionNamedType $reflectionPropertyType */ |
|
|
|
/** @var \ReflectionNamedType $reflectionPropertyType */ |
|
|
|
$reflectionPropertyType = $property->getType(); |
|
|
|
$reflectionPropertyType = $property->getType(); |
|
|
@ -135,4 +146,16 @@ class Data2DtoConverter |
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private function grabPropertyDTOClass(\ReflectionProperty $property): ?string |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$attributedPropertyClass = null; |
|
|
|
|
|
|
|
$propertyName = $property->getName(); |
|
|
|
|
|
|
|
$propertyExtractor = new PropertyExtractor($property->class, $propertyName); |
|
|
|
|
|
|
|
/** @var DTOMeta $dtoMeta */ |
|
|
|
|
|
|
|
if ($dtoMeta = $propertyExtractor->fetch(DTOMeta::class)) { |
|
|
|
|
|
|
|
$attributedPropertyClass = $dtoMeta->class; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return $attributedPropertyClass; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |