public function createContentDraftAction(
        $contentId,
        $fromVersionNo = null,
        $fromLanguage = null,
        $toLanguage = null,
        Request $request
    ) {
        $createContentDraft = new CreateContentDraftData();
        $contentInfo = null;
        $contentType = null;

        if ($contentId !== null) {
            $createContentDraft->contentId = $contentId;

            $contentInfo = $this->contentService->loadContentInfo($contentId);
            $contentType = $this->contentTypeService->loadContentType($contentInfo->contentTypeId);
            $createContentDraft->fromVersionNo = $fromVersionNo ?: $contentInfo->currentVersionNo;
            $createContentDraft->fromLanguage = $fromLanguage ?: $contentInfo->mainLanguageCode;
        }

        $form = $this->createForm(
            ContentDraftCreateType::class,
            $createContentDraft,
            [
                'action' => $this->generateUrl('ez_content_draft_create'),
            ]
        );

        $form->handleRequest($request);

        if ($form->isValid() && null !== $form->getClickedButton()) {
            $this->contentActionDispatcher->dispatchFormAction($form, $createContentDraft, $form->getClickedButton()->getName());
            if ($response = $this->contentActionDispatcher->getResponse()) {
                return $response;
            }
        }

        return new ContentCreateDraftView(null, [
            'form' => $form->createView(),
            'contentInfo' => $contentInfo,
            'contentType' => $contentType,
        ]);
    }
public function createContentDraftAction(
        $contentId,
        $fromVersionNo = null,
        $fromLanguage = null,
        $toLanguage = null,
        Request $request
    ) {
        $createContentDraft = new CreateContentDraftData();
        $contentInfo = null;
        $contentType = null;

        if ($contentId !== null) {
            $createContentDraft->contentId = $contentId;

            $contentInfo = $this->contentService->loadContentInfo($contentId);
            $contentType = $this->contentTypeService->loadContentType($contentInfo->contentTypeId);
            $createContentDraft->fromVersionNo = $fromVersionNo ?: $contentInfo->currentVersionNo;
            $createContentDraft->fromLanguage = $fromLanguage ?: $contentInfo->mainLanguageCode;
        }

        $form = $this->createForm(
            ContentDraftCreateType::class,
            $createContentDraft,
            [
                'action' => $this->generateUrl('ez_content_draft_create'),
            ]
        );

        $form->handleRequest($request);

        if ($form->isValid() && null !== $form->getClickedButton()) {
            $this->contentActionDispatcher->dispatchFormAction($form, $createContentDraft, $form->getClickedButton()->getName());
            if ($response = $this->contentActionDispatcher->getResponse()) {
                return $response;
            }
        }

        return new ContentCreateDraftView(null, [
            'form' => $form->createView(),
            'contentInfo' => $contentInfo,
            'contentType' => $contentType,
        ]);
    }
public function createContentDraftAction ( $ contentId , $ fromVersionNo = null , $ fromLanguage = null , $ toLanguage = null , Request $ request ) { $ createContentDraft = new CreateContentDraftData ( ) ; $ contentInfo = null ; $ contentType = null ; if ( $ contentId !== null ) { $ createContentDraft -> contentId = $ contentId ; $ contentInfo = $ this -> contentService -> loadContentInfo ( $ contentId ) ; $ contentType = $ this -> contentTypeService -> loadContentType ( $ contentInfo -> contentTypeId ) ; $ createContentDraft -> fromVersionNo = $ fromVersionNo ? : $ contentInfo -> currentVersionNo ; $ createContentDraft -> fromLanguage = $ fromLanguage ? : $ contentInfo -> mainLanguageCode ; } $ form = $ this -> createForm ( ContentDraftCreateType :: class , $ createContentDraft , [ 'action' => $ this -> generateUrl ( 'ez_content_draft_create' ) , ] ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) && null !== $ form -> getClickedButton ( ) ) { $ this -> contentActionDispatcher -> dispatchFormAction ( $ form , $ createContentDraft , $ form -> getClickedButton ( ) -> getName ( ) ) ; if ( $ response = $ this -> contentActionDispatcher -> getResponse ( ) ) { return $ response ; } } return new ContentCreateDraftView ( null , [ 'form' => $ form -> createView ( ) , 'contentInfo' => $ contentInfo , 'contentType' => $ contentType , ] ) ; }
Displays a draft creation form that creates a content draft from an existing content.

@param mixed $contentId
@param int $fromVersionNo
@param string $fromLanguage
@param string $toLanguage
@param \Symfony\Component\HttpFoundation\Request $request

@return \EzSystems\RepositoryForms\Content\View\ContentCreateDraftView|\Symfony\Component\HttpFoundation\Response

@throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
@throws \eZ\Publish\API\Repository\Exceptions\NotFoundException
@throws \eZ\Publish\Core\Base\Exceptions\InvalidArgumentType
Displays a draft creation form that creates a content draft from an existing content .