protected function convertChangeData($changeData)
    {
        $type = $changeData['type'];

        if (!isset($this->typeMap[$type])) {
            return new Error(sprintf('Could not convert change type %s, it is unknown to the system', $type));
        }

        $changeClass = $this->typeMap[$type];
        $changeClassInstance = $this->objectManager->get($changeClass);
        $changeClassInstance->injectPersistenceManager($this->persistenceManager);

        $subjectContextPath = $changeData['subject'];
        $subject = $this->nodeService->getNodeFromContextPath($subjectContextPath);

        if ($subject instanceof Error) {
            return $subject;
        }

        $changeClassInstance->setSubject($subject);

        if (isset($changeData['reference']) && method_exists($changeClassInstance, 'setReference')) {
            $referenceContextPath = $changeData['reference'];
            $reference = $this->nodeService->getNodeFromContextPath($referenceContextPath);

            if ($reference instanceof Error) {
                return $reference;
            }

            $changeClassInstance->setReference($reference);
        }

        if (isset($changeData['payload'])) {
            foreach ($changeData['payload'] as $propertyName => $value) {
                if (!in_array($propertyName, $this->disallowedPayloadProperties)) {
                    $methodParameters = $this->reflectionService->getMethodParameters($changeClass, ObjectAccess::buildSetterMethodName($propertyName));
                    $methodParameter = current($methodParameters);
                    $targetType = $methodParameter['type'];

                    // Fixme: The type conversion runs depending on the target node property type inside Property::class
                    // This is why we are not allowed to modify the value in any way.
                    // Without this condition the object was parsed to a string leading to fatal errors when changing images
                    // in the UI.
                    if ($propertyName !== 'value' && $targetType !== Property::class) {
                        $value = $this->propertyMapper->convert($value, $targetType);
                    }

                    ObjectAccess::setProperty($changeClassInstance, $propertyName, $value);
                }
            }
        }

        return $changeClassInstance;
    }
protected function convertChangeData($changeData)
    {
        $type = $changeData['type'];

        if (!isset($this->typeMap[$type])) {
            return new Error(sprintf('Could not convert change type %s, it is unknown to the system', $type));
        }

        $changeClass = $this->typeMap[$type];
        $changeClassInstance = $this->objectManager->get($changeClass);
        $changeClassInstance->injectPersistenceManager($this->persistenceManager);

        $subjectContextPath = $changeData['subject'];
        $subject = $this->nodeService->getNodeFromContextPath($subjectContextPath);

        if ($subject instanceof Error) {
            return $subject;
        }

        $changeClassInstance->setSubject($subject);

        if (isset($changeData['reference']) && method_exists($changeClassInstance, 'setReference')) {
            $referenceContextPath = $changeData['reference'];
            $reference = $this->nodeService->getNodeFromContextPath($referenceContextPath);

            if ($reference instanceof Error) {
                return $reference;
            }

            $changeClassInstance->setReference($reference);
        }

        if (isset($changeData['payload'])) {
            foreach ($changeData['payload'] as $propertyName => $value) {
                if (!in_array($propertyName, $this->disallowedPayloadProperties)) {
                    $methodParameters = $this->reflectionService->getMethodParameters($changeClass, ObjectAccess::buildSetterMethodName($propertyName));
                    $methodParameter = current($methodParameters);
                    $targetType = $methodParameter['type'];

                    // Fixme: The type conversion runs depending on the target node property type inside Property::class
                    // This is why we are not allowed to modify the value in any way.
                    // Without this condition the object was parsed to a string leading to fatal errors when changing images
                    // in the UI.
                    if ($propertyName !== 'value' && $targetType !== Property::class) {
                        $value = $this->propertyMapper->convert($value, $targetType);
                    }

                    ObjectAccess::setProperty($changeClassInstance, $propertyName, $value);
                }
            }
        }

        return $changeClassInstance;
    }
protected function convertChangeData ( $ changeData ) { $ type = $ changeData [ 'type' ] ; if ( ! isset ( $ this -> typeMap [ $ type ] ) ) { return new Error ( sprintf ( 'Could not convert change type %s, it is unknown to the system' , $ type ) ) ; } $ changeClass = $ this -> typeMap [ $ type ] ; $ changeClassInstance = $ this -> objectManager -> get ( $ changeClass ) ; $ changeClassInstance -> injectPersistenceManager ( $ this -> persistenceManager ) ; $ subjectContextPath = $ changeData [ 'subject' ] ; $ subject = $ this -> nodeService -> getNodeFromContextPath ( $ subjectContextPath ) ; if ( $ subject instanceof Error ) { return $ subject ; } $ changeClassInstance -> setSubject ( $ subject ) ; if ( isset ( $ changeData [ 'reference' ] ) && method_exists ( $ changeClassInstance , 'setReference' ) ) { $ referenceContextPath = $ changeData [ 'reference' ] ; $ reference = $ this -> nodeService -> getNodeFromContextPath ( $ referenceContextPath ) ; if ( $ reference instanceof Error ) { return $ reference ; } $ changeClassInstance -> setReference ( $ reference ) ; } if ( isset ( $ changeData [ 'payload' ] ) ) { foreach ( $ changeData [ 'payload' ] as $ propertyName => $ value ) { if ( ! in_array ( $ propertyName , $ this -> disallowedPayloadProperties ) ) { $ methodParameters = $ this -> reflectionService -> getMethodParameters ( $ changeClass , ObjectAccess :: buildSetterMethodName ( $ propertyName ) ) ; $ methodParameter = current ( $ methodParameters ) ; $ targetType = $ methodParameter [ 'type' ] ; // Fixme: The type conversion runs depending on the target node property type inside Property::class // This is why we are not allowed to modify the value in any way. // Without this condition the object was parsed to a string leading to fatal errors when changing images // in the UI. if ( $ propertyName !== 'value' && $ targetType !== Property :: class ) { $ value = $ this -> propertyMapper -> convert ( $ value , $ targetType ) ; } ObjectAccess :: setProperty ( $ changeClassInstance , $ propertyName , $ value ) ; } } } return $ changeClassInstance ; }
Convert array to change interface

@param array $changeData
@return ChangeInterface
Convert array to change interface