Skip to content

Commit

Permalink
fix: Code Review
Browse files Browse the repository at this point in the history
  • Loading branch information
Nattfarinn committed Oct 13, 2020
1 parent a618b6f commit 36fc5b6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/bundle/Controller/ContentOnTheFlyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@

class ContentOnTheFlyController extends Controller
{
private const AUTOSAVE_ACTION_NAME = 'autosave';

/** @var \eZ\Publish\API\Repository\ContentService */
private $contentService;

Expand Down Expand Up @@ -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)) {
Expand All @@ -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;
Expand Down

0 comments on commit 36fc5b6

Please # to comment.