diff --git a/src/bundle/Controller/ContentController.php b/src/bundle/Controller/ContentController.php index 4416239e8c..2dcbbf7035 100644 --- a/src/bundle/Controller/ContentController.php +++ b/src/bundle/Controller/ContentController.php @@ -12,7 +12,7 @@ use eZ\Publish\API\Repository\Values\Content\Content; use EzSystems\EzPlatformAdminUi\Exception\InvalidArgumentException as AdminInvalidArgumentException; use EzSystems\EzPlatformAdminUi\Form\Data\Content\Draft\ContentCreateData; -use EzSystems\EzPlatformAdminUi\Form\Data\Content\Draft\ContentDraftCreateData; +use EzSystems\EzPlatformAdminUi\Form\Data\Content\Draft\ContentEditData; use EzSystems\EzPlatformAdminUi\Form\Data\Content\Location\ContentMainLocationUpdateData; use EzSystems\EzPlatformAdminUi\Form\DataMapper\ContentMainLocationUpdateMapper; use EzSystems\EzPlatformAdminUi\Form\Factory\FormFactory; @@ -124,18 +124,22 @@ public function createAction(Request $request): Response * @throws UnauthorizedException * @throws InvalidOptionsException */ - public function createDraftAction(Request $request): Response + public function editAction(Request $request): Response { - $form = $this->formFactory->createContentDraft(); + $form = $this->formFactory->contentEdit(); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { - $result = $this->submitHandler->handle($form, function (ContentDraftCreateData $data) { + $result = $this->submitHandler->handle($form, function (ContentEditData $data) { $contentInfo = $data->getContentInfo(); $versionInfo = $data->getVersionInfo(); $language = $data->getLanguage(); + $versionNo = $versionInfo->versionNo; - $contentDraft = $this->contentService->createContentDraft($contentInfo, $versionInfo); + if (!$versionInfo->isDraft()) { + $contentDraft = $this->contentService->createContentDraft($contentInfo, $versionInfo); + $versionNo = $contentDraft->getVersionInfo()->versionNo; + } $this->notificationHandler->success( $this->translator->trans( @@ -148,7 +152,7 @@ public function createDraftAction(Request $request): Response return $this->redirectToRoute('ez_content_draft_edit', [ 'contentId' => $contentInfo->id, - 'versionNo' => $contentDraft->getVersionInfo()->versionNo, + 'versionNo' => $versionNo, 'language' => $language->languageCode, ]); }); @@ -158,7 +162,7 @@ public function createDraftAction(Request $request): Response } } - /** @var ContentDraftCreateData $data */ + /** @var ContentEditData $data */ $data = $form->getData(); $contentInfo = $data->getContentInfo(); @@ -216,7 +220,7 @@ public function updateMainLocationAction(Request $request): Response } } - /** @var ContentDraftCreateData $data */ + /** @var ContentEditData $data */ $data = $form->getData(); $contentInfo = $data->getContentInfo(); diff --git a/src/bundle/Controller/ContentViewController.php b/src/bundle/Controller/ContentViewController.php index e8390c6d6a..28624caabd 100644 --- a/src/bundle/Controller/ContentViewController.php +++ b/src/bundle/Controller/ContentViewController.php @@ -11,7 +11,7 @@ use eZ\Publish\API\Repository\Values\Content\Location; use eZ\Publish\Core\MVC\Symfony\View\ContentView; use EzSystems\EzPlatformAdminUi\Form\Data\Content\Draft\ContentCreateData; -use EzSystems\EzPlatformAdminUi\Form\Data\Content\Draft\ContentDraftCreateData; +use EzSystems\EzPlatformAdminUi\Form\Data\Content\Draft\ContentEditData; use EzSystems\EzPlatformAdminUi\Form\Data\Location\LocationCopyData; use EzSystems\EzPlatformAdminUi\Form\Data\Location\LocationMoveData; use EzSystems\EzPlatformAdminUi\Form\Data\Location\LocationTrashData; @@ -101,8 +101,8 @@ private function supplyContentActionForms(ContentView $view): void new LocationTrashData($location) ); - $contentDraftCreateType = $this->formFactory->createContentDraft( - new ContentDraftCreateData($content->contentInfo, $versionInfo) + $contentEditType = $this->formFactory->contentEdit( + new ContentEditData($content->contentInfo, $versionInfo) ); $contentCreateType = $this->formFactory->createContent( @@ -113,7 +113,7 @@ private function supplyContentActionForms(ContentView $view): void 'form_location_copy' => $locationCopyType->createView(), 'form_location_move' => $locationMoveType->createView(), 'form_location_trash' => $locationTrashType->createView(), - 'form_content_draft_create' => $contentDraftCreateType->createView(), + 'form_content_edit' => $contentEditType->createView(), 'form_content_create' => $contentCreateType->createView(), ]); } diff --git a/src/bundle/Resources/config/routing.yml b/src/bundle/Resources/config/routing.yml index 705c26cb45..e18b3dc468 100644 --- a/src/bundle/Resources/config/routing.yml +++ b/src/bundle/Resources/config/routing.yml @@ -447,11 +447,11 @@ ezplatform.content.update_main_location: # Content Edit # -ezplatform.content_draft.create: - path: /content/draft/create # @todo change to /content/draft/create once route is removed from repository-forms +ezplatform.content.edit: + path: /content/edit methods: ['POST'] defaults: - _controller: 'EzPlatformAdminUiBundle:Content:createDraft' + _controller: 'EzPlatformAdminUiBundle:Content:edit' ezplatform.content.create: path: /content/create diff --git a/src/bundle/Resources/views/content/locationview.html.twig b/src/bundle/Resources/views/content/locationview.html.twig index dd8c476a86..c727eb6146 100644 --- a/src/bundle/Resources/views/content/locationview.html.twig +++ b/src/bundle/Resources/views/content/locationview.html.twig @@ -4,7 +4,7 @@ {% form_theme form_location_copy '@EzPlatformAdminUi/parts/form/flat_widgets.html.twig' %} {% form_theme form_location_move '@EzPlatformAdminUi/parts/form/flat_widgets.html.twig' %} {% form_theme form_location_trash '@EzPlatformAdminUi/parts/form/flat_widgets.html.twig' %} -{% form_theme form_content_draft_create '@EzPlatformAdminUi/parts/form/flat_widgets.html.twig' %} +{% form_theme form_content_edit '@EzPlatformAdminUi/parts/form/flat_widgets.html.twig' %} {% form_theme form_content_create '@EzPlatformAdminUi/parts/form/flat_widgets.html.twig' '@EzPlatformAdminUi/form_fields.html.twig' %} {% block bodyClass %}ez-content-view{% endblock %} @@ -61,7 +61,7 @@