CodeExplorer getNestedAttributes example
if (null ===
$data &&
isset($context['value_type'
]) &&
$context['value_type'
] instanceof Type &&
$context['value_type'
]->
isNullable()) { return null;
} $allowedAttributes =
$this->
getAllowedAttributes($type,
$context, true
);
$normalizedData =
$this->
prepareForDenormalization($data);
$extraAttributes =
[];
$mappedClass =
$this->
getMappedClass($normalizedData,
$type,
$context);
$nestedAttributes =
$this->
getNestedAttributes($mappedClass);
$nestedData =
$originalNestedData =
[];
$propertyAccessor = PropertyAccess::
createPropertyAccessor();
foreach ($nestedAttributes as $property =>
$serializedPath) { if (null ===
$value =
$propertyAccessor->
getValue($normalizedData,
$serializedPath)) { continue;
} $convertedProperty =
$this->nameConverter ?
$this->nameConverter->
normalize($property,
$mappedClass,
$format,
$context) :
$property;
$nestedData[$convertedProperty] =
$value;
$originalNestedData[$property] =
$value;
$normalizedData =
$this->
removeNestedValue($serializedPath->
getElements(),
$normalizedData);
} if (null ===
$data &&
isset($context['value_type'
]) &&
$context['value_type'
] instanceof Type &&
$context['value_type'
]->
isNullable()) { return null;
} $allowedAttributes =
$this->
getAllowedAttributes($type,
$context, true
);
$normalizedData =
$this->
prepareForDenormalization($data);
$extraAttributes =
[];
$mappedClass =
$this->
getMappedClass($normalizedData,
$type,
$context);
$nestedAttributes =
$this->
getNestedAttributes($mappedClass);
$nestedData =
$originalNestedData =
[];
$propertyAccessor = PropertyAccess::
createPropertyAccessor();
foreach ($nestedAttributes as $property =>
$serializedPath) { if (null ===
$value =
$propertyAccessor->
getValue($normalizedData,
$serializedPath)) { continue;
} $convertedProperty =
$this->nameConverter ?
$this->nameConverter->
normalize($property,
$mappedClass,
$format,
$context) :
$property;
$nestedData[$convertedProperty] =
$value;
$originalNestedData[$property] =
$value;
$normalizedData =
$this->
removeNestedValue($serializedPath->
getElements(),
$normalizedData);
}