removeNestedValue example

$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);
        }

        $normalizedData = array_merge($normalizedData$nestedData);

        $object = $this->instantiateObject($normalizedData$mappedClass$contextnew \ReflectionClass($mappedClass)$allowedAttributes$format);
        $resolvedClass = ($this->objectClassResolver)($object);

        foreach ($normalizedData as $attribute => $value) {
            if ($this->nameConverter) {
                $notConverted = $attribute;
                $attribute = $this->nameConverter->denormalize($attribute$resolvedClass$format$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);
        }

        $normalizedData = array_merge($normalizedData$nestedData);

        $object = $this->instantiateObject($normalizedData$mappedClass$contextnew \ReflectionClass($mappedClass)$allowedAttributes$format);
        $resolvedClass = ($this->objectClassResolver)($object);

        foreach ($normalizedData as $attribute => $value) {
            if ($this->nameConverter) {
                $notConverted = $attribute;
                $attribute = $this->nameConverter->denormalize($attribute$resolvedClass$format$context);
                
Home | Imprint | This part of the site doesn't use cookies.