/** * @static * * @param Node $pNode * @param array $pBoxedContents */ function installContents(Node $pNode, $pBoxedContents) { if (!is_array($pBoxedContents)) { return; } /** * 0: type74 * 1: title * 2: template * 3: content * */ foreach ($pBoxedContents as $boxId => $contents) { foreach ($contents as $content) { $oContent = new Content(); $oContent->setNodeId($pNode->getId()); $oContent->setBoxId($boxId); $oContent->setType($content[0]); $oContent->setTemplate($content[2]); $oContent->setContent($content[3]); $oContent->save(); } } }
/** * @ApiDoc( * section="Administration", * description="Returns a renderer content element as preview for Jarves page editor" * ) * * @Rest\QueryParam(name="template", requirements=".+", strict=true, * description="The template/view to be used for this content") * * @Rest\QueryParam(name="type", requirements=".+", strict=true, description="The content type") * * @Rest\QueryParam(name="nodeId", requirements="[0-9]+", * description="The node id in which context this content should be rendered") * @Rest\QueryParam(name="domainId", requirements="[0-9]+", * description="The domain id in which context this content should be rendered") * @Rest\RequestParam(name="content", requirements=".*", description="The actual content") * * @Rest\Post("/admin/content/preview") * * @param ParamFetcher $paramFetcher * * @return array */ public function getContentPreviewAction(ParamFetcher $paramFetcher) { $template = $paramFetcher->get('template'); $type = $paramFetcher->get('type'); $content = $paramFetcher->get('content'); $nodeId = $paramFetcher->get('nodeId'); $domainId = $paramFetcher->get('domainId'); //todo, check if $template is defined as content template $contentObject = new Content(); $contentObject->setType($type); $contentObject->setTemplate($template); $contentObject->setContent($content); if ($domainId) { $domain = $this->pageStack->getDomain($domainId); $this->pageStack->setCurrentDomain($domain); } if ($nodeId) { $page = $this->pageStack->getPage($nodeId); $this->pageStack->setCurrentPage($page); } return $this->contentRender->renderContent($contentObject, ['preview' => true]); }