Skip to content

Commit

Permalink
Merge pull request #3304 from insiders/form-preview
Browse files Browse the repository at this point in the history
[FormBundle] Fix draft version form page
  • Loading branch information
acrobat authored Dec 20, 2023
2 parents e92e3ce + f7b156a commit cf8e07e
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Doctrine\ORM\EntityManagerInterface;
use Kunstmaan\FormBundle\Helper\FormHandlerInterface;
use Kunstmaan\NodeBundle\Entity\NodeTranslation;
use Kunstmaan\NodeBundle\Entity\NodeVersion;
use Kunstmaan\NodeBundle\Entity\PageViewDataProviderInterface;
use Kunstmaan\NodeBundle\Helper\RenderContext;
use Symfony\Component\HttpFoundation\RequestStack;
Expand Down Expand Up @@ -36,7 +37,19 @@ public function provideViewData(NodeTranslation $nodeTranslation, RenderContext
}

$thanksParam = $request->query->get('thanks');
$entity = $nodeTranslation->getRef($this->em);

$entity = null;
$version = $request->query->get('version');
if (!empty($version) && is_numeric($version)) {
$nodeVersion = $this->em->getRepository(NodeVersion::class)->find($version);
if (!\is_null($nodeVersion)) {
$entity = $nodeVersion->getRef($this->em);
}
}
if (!$entity) {
$entity = $nodeTranslation->getRef($this->em);
}

$renderContext['nodetranslation'] = $nodeTranslation;
$renderContext['slug'] = $request->attributes->get('url');
$renderContext['page'] = $entity;
Expand Down

0 comments on commit cf8e07e

Please sign in to comment.