Neos\Flow\Persistence\Generic\DataMapper::thawProperties PHP Method

thawProperties() public method

Sets the given properties on the object.
public thawProperties ( object $object, string $identifier, array $objectData ) : void
$object object The object to set properties on
$identifier string The identifier of the object
$objectData array
return void
    public function thawProperties($object, $identifier, array $objectData)
    {
        $classSchema = $this->reflectionService->getClassSchema($objectData['classname']);
        foreach ($objectData['properties'] as $propertyName => $propertyData) {
            if (!$classSchema->hasProperty($propertyName) || $classSchema->isPropertyTransient($propertyName)) {
                continue;
            }
            $propertyValue = null;
            if ($propertyData['value'] !== null) {
                switch ($propertyData['type']) {
                    case 'integer':
                        $propertyValue = (int) $propertyData['value'];
                        break;
                    case 'float':
                        $propertyValue = (double) $propertyData['value'];
                        break;
                    case 'boolean':
                        $propertyValue = (bool) $propertyData['value'];
                        break;
                    case 'string':
                        $propertyValue = (string) $propertyData['value'];
                        break;
                    case 'array':
                        $propertyValue = $this->mapArray($propertyData['value']);
                        break;
                    case 'Doctrine\\Common\\Collections\\Collection':
                    case 'Doctrine\\Common\\Collections\\ArrayCollection':
                        $propertyValue = new ArrayCollection($this->mapArray($propertyData['value']));
                        break;
                    case 'SplObjectStorage':
                        $propertyValue = $this->mapSplObjectStorage($propertyData['value'], $classSchema->isPropertyLazy($propertyName));
                        break;
                    case 'DateTime':
                        $propertyValue = $this->mapDateTime($propertyData['value']);
                        break;
                    default:
                        if ($propertyData['value'] === false) {
                            throw new UnknownObjectException('An expected object was not found by the backend. It was expected for ' . $objectData['classname'] . '::' . $propertyName, 1289509867);
                        }
                        $propertyValue = $this->mapToObject($propertyData['value']);
                        break;
                }
            } else {
                switch ($propertyData['type']) {
                    case 'NULL':
                        continue;
                    case 'array':
                        $propertyValue = $this->mapArray(null);
                        break;
                    case Collection::class:
                    case ArrayCollection::class:
                        $propertyValue = new ArrayCollection();
                        break;
                    case 'SplObjectStorage':
                        $propertyValue = $this->mapSplObjectStorage(null);
                        break;
                }
            }
            ObjectAccess::setProperty($object, $propertyName, $propertyValue, true);
        }
        if (isset($objectData['metadata'])) {
            $object->Flow_Persistence_Metadata = $objectData['metadata'];
        }
        ObjectAccess::setProperty($object, 'Persistence_Object_Identifier', $identifier, true);
    }