示例#1
0
 public function render()
 {
     if ($this->getContent()->getContent()) {
         $value = json_decode($this->getContent()->getContent(), true);
         $nodeId = $value['node'] + 0;
         return $this->contentRender->renderSlot($nodeId);
     }
 }
示例#2
0
 /**
  * @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]);
 }