From 36fc5b6c42f327445cca35fa42c665997ff5fa3d Mon Sep 17 00:00:00 2001 From: Nattfarinn Date: Tue, 13 Oct 2020 14:31:58 +0200 Subject: [PATCH] fix: Code Review --- src/bundle/Controller/ContentOnTheFlyController.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/bundle/Controller/ContentOnTheFlyController.php b/src/bundle/Controller/ContentOnTheFlyController.php index 4d2e938b8e..61b964b1e0 100644 --- a/src/bundle/Controller/ContentOnTheFlyController.php +++ b/src/bundle/Controller/ContentOnTheFlyController.php @@ -40,6 +40,8 @@ class ContentOnTheFlyController extends Controller { + private const AUTOSAVE_ACTION_NAME = 'autosave'; + /** @var \eZ\Publish\API\Repository\ContentService */ private $contentService; @@ -289,11 +291,11 @@ public function editContentAction( if ($form->isSubmitted() && $form->isValid() && null !== $form->getClickedButton()) { $actionName = $form->getClickedButton()->getName(); - $actionDispatcher = $actionName === 'autosave' + $actionDispatcher = $actionName === self::AUTOSAVE_ACTION_NAME ? $this->contentActionDispatcher : $this->createContentActionDispatcher; - if (empty($location)) { + if (!$location instanceof Location) { $contentInfo = $this->contentService->loadContentInfo($content->id); if (!empty($contentInfo->mainLocationId)) { @@ -304,14 +306,14 @@ public function editContentAction( $actionDispatcher->dispatchFormAction( $form, $form->getData(), - $form->getClickedButton()->getName(), + $actionName, ['referrerLocation' => $location] ); if ($actionDispatcher->getResponse()) { $view = new EditContentOnTheFlySuccessView('@ezdesign/ui/on_the_fly/content_edit_response.html.twig'); $view->addParameters([ - 'locationId' => empty($location) ? null : $location->id, + 'locationId' => $location instanceof Location ? $location->id : null, ]); return $view;