/** * Returns localization properties, inner html and placeholder contents. * * @return SupraJsonResponse */ public function getAction() { $localization = $this->getPageLocalization(); $pageRequest = $this->createPageRequest(); $pageController = $this->getPageController(); $templateException = $response = $internalHtml = null; try { $response = $pageController->execute($pageRequest); } catch (\Twig_Error_Loader $e) { $templateException = $e; } catch (LayoutNotFound $e) { $templateException = $e; } catch (\Exception $e) { throw $e; } $localizationData = $this->getLocalizationData($localization); if ($templateException) { $internalHtml = '<h1>Page template or layout not found.</h1> <p>Please make sure the template is assigned and the template is published in this locale and it has layout assigned.</p>'; } elseif ($response instanceof Response) { $internalHtml = $response->getContent(); } $localizationData['internal_html'] = $internalHtml; $placeHolders = $pageRequest->getPlaceHolderSet()->getFinalPlaceHolders(); $blocks = $pageRequest->getBlockSet(); $placeHoldersData =& $localizationData['contents']; foreach ($placeHolders as $placeHolder) { $blocksData = array(); foreach ($blocks->getPlaceHolderBlockSet($placeHolder) as $block) { /* @var $block Block */ $blocksData[] = $this->getBlockData($block); } $placeHolderData = array('id' => $placeHolder->getName(), 'title' => $placeHolder->getTitle(), 'locked' => $placeHolder->isLocked(), 'closed' => !$localization->isPlaceHolderEditable($placeHolder), 'contents' => $blocksData, 'type' => 'list'); $placeHoldersData[] = $placeHolderData; } $jsonResponse = new SupraJsonResponse($localizationData); // @FIXME: dummy. when needed, move to prefilter. $jsonResponse->setPermissions(array(array('edit_page' => true, 'supervise_page' => true))); return $jsonResponse; }