public function createContentDraft(FormActionEvent $event): void
    {
        /** @var ContentTranslationData $data */
        $data = $event->getData();

        if (!$data instanceof ContentTranslationData) {
            return;
        }

        $contentDraft = $this->contentService->createContentDraft($data->content->contentInfo);
        $fields = array_filter($data->fieldsData, function (FieldData $fieldData) use ($contentDraft, $data) {
            $mainLanguageCode = $contentDraft->getVersionInfo()->getContentInfo()->mainLanguageCode;

            return $mainLanguageCode === $data->initialLanguageCode
                || ($mainLanguageCode !== $data->initialLanguageCode && $fieldData->fieldDefinition->isTranslatable);
        });
        $contentUpdateData = new ContentUpdateData([
            'initialLanguageCode' => $data->initialLanguageCode,
            'contentDraft' => $contentDraft,
            'fieldsData' => $fields,
        ]);

        $event->setData($contentUpdateData);
    }
public function createContentDraft(FormActionEvent $event): void
    {
        /** @var ContentTranslationData $data */
        $data = $event->getData();

        if (!$data instanceof ContentTranslationData) {
            return;
        }

        $contentDraft = $this->contentService->createContentDraft($data->content->contentInfo);
        $fields = array_filter($data->fieldsData, function (FieldData $fieldData) use ($contentDraft, $data) {
            $mainLanguageCode = $contentDraft->getVersionInfo()->getContentInfo()->mainLanguageCode;

            return $mainLanguageCode === $data->initialLanguageCode
                || ($mainLanguageCode !== $data->initialLanguageCode && $fieldData->fieldDefinition->isTranslatable);
        });
        $contentUpdateData = new ContentUpdateData([
            'initialLanguageCode' => $data->initialLanguageCode,
            'contentDraft' => $contentDraft,
            'fieldsData' => $fields,
        ]);

        $event->setData($contentUpdateData);
    }
public function createContentDraft ( FormActionEvent $ event ) : void { /** @var ContentTranslationData $data */ $ data = $ event -> getData ( ) ; if ( ! $ data instanceof ContentTranslationData ) { return ; } $ contentDraft = $ this -> contentService -> createContentDraft ( $ data -> content -> contentInfo ) ; $ fields = array_filter ( $ data -> fieldsData , function ( FieldData $ fieldData ) use ( $ contentDraft , $ data ) { $ mainLanguageCode = $ contentDraft -> getVersionInfo ( ) -> getContentInfo ( ) -> mainLanguageCode ; return $ mainLanguageCode === $ data -> initialLanguageCode || ( $ mainLanguageCode !== $ data -> initialLanguageCode && $ fieldData -> fieldDefinition -> isTranslatable ) ; } ) ; $ contentUpdateData = new ContentUpdateData ( [ 'initialLanguageCode' => $ data -> initialLanguageCode , 'contentDraft' => $ contentDraft , 'fieldsData' => $ fields , ] ) ; $ event -> setData ( $ contentUpdateData ) ; }
Creates content draft based in data submitted by the user and injects ContentUpdateData to the event.

This step is required to achieve compatibility with other FormProcessors.

@param FormActionEvent $event
Creates content draft based in data submitted by the user and injects ContentUpdateData to the event .