Skip to content

Commit

Permalink
Merge pull request #645 from samuele-mrapps/patch-1
Browse files Browse the repository at this point in the history
[NodeBundle] fix reorder method in case the node hasn't been translated
  • Loading branch information
Roderik van der Veer committed Aug 22, 2015
2 parents d2791f0 + 74d6df1 commit d8fd342
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions src/Kunstmaan/NodeBundle/Controller/NodeAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -779,24 +779,27 @@ public function reorderAction(Request $request)

/* @var NodeTranslation $nodeTranslation */
$nodeTranslation = $node->getNodeTranslation($this->locale, true);
$nodeVersion = $nodeTranslation->getPublicNodeVersion();
$page = $nodeVersion->getRef($this->em);

if ($nodeTranslation) {
$nodeVersion = $nodeTranslation->getPublicNodeVersion();
$page = $nodeVersion->getRef($this->em);

$this->get('event_dispatcher')->dispatch(
Events::PRE_PERSIST,
new NodeEvent($node, $nodeTranslation, $nodeVersion, $page)
);
$this->get('event_dispatcher')->dispatch(
Events::PRE_PERSIST,
new NodeEvent($node, $nodeTranslation, $nodeVersion, $page)
);

$nodeTranslation->setWeight($weight);
$this->em->persist($nodeTranslation);
$this->em->flush($nodeTranslation);
$nodeTranslation->setWeight($weight);
$this->em->persist($nodeTranslation);
$this->em->flush($nodeTranslation);

$this->get('event_dispatcher')->dispatch(
Events::POST_PERSIST,
new NodeEvent($node, $nodeTranslation, $nodeVersion, $page)
);
$this->get('event_dispatcher')->dispatch(
Events::POST_PERSIST,
new NodeEvent($node, $nodeTranslation, $nodeVersion, $page)
);

$weight++;
$weight++;
}
}

return new JsonResponse(
Expand Down

0 comments on commit d8fd342

Please sign in to comment.