Настроил сохранение в приватные свойства
This commit is contained in:
parent
5fa62d248e
commit
02f5719514
@ -59,7 +59,7 @@ class Data2DtoConverter
|
||||
continue;
|
||||
}
|
||||
|
||||
$property->setValue($object, $value);
|
||||
$this->setValue($object, $property, $value);
|
||||
}
|
||||
|
||||
return $object;
|
||||
@ -80,7 +80,7 @@ class Data2DtoConverter
|
||||
$value = $this->convert($data, new $propertyType, $tags);
|
||||
}
|
||||
// присваиваем получившееся значение
|
||||
$property->setValue($object, $value);
|
||||
$this->setValue($object, $property, $value);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -92,7 +92,7 @@ class Data2DtoConverter
|
||||
protected function processDataObject(object $object, \ReflectionProperty $property, $value): bool
|
||||
{
|
||||
if (is_object($value)) {
|
||||
$property->setValue($object, $value);
|
||||
$this->setValue($object, $property, $value);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -263,4 +263,17 @@ class Data2DtoConverter
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private function setValue(object $object, \ReflectionProperty $property, $value)
|
||||
{
|
||||
if (!$property->isPublic()) {
|
||||
$property->setAccessible(true);
|
||||
}
|
||||
|
||||
$property->setValue($object, $value);
|
||||
|
||||
if (!$property->isPublic()) {
|
||||
$property->setAccessible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user