From 95ad78bc3c2b97fe417808fd2cca8028d961e12c Mon Sep 17 00:00:00 2001 From: Bartek Wajda Date: Wed, 18 Jan 2023 11:01:55 +0100 Subject: [PATCH 1/4] IBX-4796: Proper redirect after content publish --- src/lib/Form/Processor/ContentFormProcessor.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/Form/Processor/ContentFormProcessor.php b/src/lib/Form/Processor/ContentFormProcessor.php index b3b4ac6..f8d048b 100644 --- a/src/lib/Form/Processor/ContentFormProcessor.php +++ b/src/lib/Form/Processor/ContentFormProcessor.php @@ -117,6 +117,7 @@ public function processPublish(FormActionEvent $event) /** @var \EzSystems\EzPlatformContentForms\Data\Content\ContentCreateData|\EzSystems\EzPlatformContentForms\Data\Content\ContentUpdateData $data */ $data = $event->getData(); $form = $event->getForm(); + $referrerLocation = $event->getOption('referrerLocation'); $draft = $this->saveDraft($data, $form->getConfig()->getOption('languageCode')); $versionInfo = $draft->versionInfo; @@ -128,7 +129,9 @@ public function processPublish(FormActionEvent $event) $redirectUrl = $form['redirectUrlAfterPublish']->getData() ?: $this->router->generate( '_ez_content_view', [ 'contentId' => $content->id, - 'locationId' => $content->contentInfo->mainLocationId, + 'locationId' => !empty($referrerLocation) + ? $referrerLocation->id + : $content->contentInfo->mainLocationId, ] ); From 160a3fe86e792171b428e498113912e521d23bbe Mon Sep 17 00:00:00 2001 From: Bartek Wajda Date: Wed, 18 Jan 2023 11:08:17 +0100 Subject: [PATCH 2/4] IBX-4796: CS --- src/lib/Form/Processor/ContentFormProcessor.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/Form/Processor/ContentFormProcessor.php b/src/lib/Form/Processor/ContentFormProcessor.php index f8d048b..b172621 100644 --- a/src/lib/Form/Processor/ContentFormProcessor.php +++ b/src/lib/Form/Processor/ContentFormProcessor.php @@ -126,12 +126,12 @@ public function processPublish(FormActionEvent $event) $event->setPayload('content', $content); $event->setPayload('is_new', $draft->contentInfo->isDraft()); + $locationId = !empty($referrerLocation) ? $referrerLocation->id : $content->contentInfo->mainLocationId; + $redirectUrl = $form['redirectUrlAfterPublish']->getData() ?: $this->router->generate( '_ez_content_view', [ 'contentId' => $content->id, - 'locationId' => !empty($referrerLocation) - ? $referrerLocation->id - : $content->contentInfo->mainLocationId, + 'locationId' => $locationId, ] ); From f49e3f5bb60209856957d3b5d5e18a021419eb1b Mon Sep 17 00:00:00 2001 From: Bartek Wajda Date: Mon, 30 Jan 2023 12:04:20 +0100 Subject: [PATCH 3/4] IBX-4796: Applied review remark --- src/lib/Form/Processor/ContentFormProcessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/Form/Processor/ContentFormProcessor.php b/src/lib/Form/Processor/ContentFormProcessor.php index b172621..849871a 100644 --- a/src/lib/Form/Processor/ContentFormProcessor.php +++ b/src/lib/Form/Processor/ContentFormProcessor.php @@ -126,7 +126,7 @@ public function processPublish(FormActionEvent $event) $event->setPayload('content', $content); $event->setPayload('is_new', $draft->contentInfo->isDraft()); - $locationId = !empty($referrerLocation) ? $referrerLocation->id : $content->contentInfo->mainLocationId; + $locationId = $referrerLocation !== null ? $referrerLocation->id : $content->contentInfo->mainLocationId; $redirectUrl = $form['redirectUrlAfterPublish']->getData() ?: $this->router->generate( '_ez_content_view', [ From 143a0d0f5a6d27af65e8b2c8d95e00ea7414feec Mon Sep 17 00:00:00 2001 From: Bartek Wajda Date: Wed, 1 Feb 2023 17:22:11 +0100 Subject: [PATCH 4/4] IBX-4796: Removed `referrerLocation` from `nodraft` actions --- src/lib/Form/Processor/ContentFormProcessor.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/Form/Processor/ContentFormProcessor.php b/src/lib/Form/Processor/ContentFormProcessor.php index 849871a..a0c0a4d 100644 --- a/src/lib/Form/Processor/ContentFormProcessor.php +++ b/src/lib/Form/Processor/ContentFormProcessor.php @@ -126,7 +126,9 @@ public function processPublish(FormActionEvent $event) $event->setPayload('content', $content); $event->setPayload('is_new', $draft->contentInfo->isDraft()); - $locationId = $referrerLocation !== null ? $referrerLocation->id : $content->contentInfo->mainLocationId; + $locationId = $referrerLocation !== null && $data instanceof ContentUpdateData + ? $referrerLocation->id + : $content->contentInfo->mainLocationId; $redirectUrl = $form['redirectUrlAfterPublish']->getData() ?: $this->router->generate( '_ez_content_view', [