/** * * @param Content|ContentInterface $content * * @return PluginResponse */ public function getPluginResponse($content) { $id = $content; if ($content instanceof Content) { $id = $content->getId(); } return isset($this->pluginResponse[$id]) ? $this->pluginResponse[$id] : ''; }
/** * Build HTML for given content. * * @param ContentInterface $content * @param array $parameters * @return string * @throws TypeNotFoundException */ public function renderContent(ContentInterface $content, $parameters = array()) { $type = $content->getType() ?: 'text'; if ('stopper' === $type) { return ''; } $title = sprintf('Content %d [%s]', $content->getId(), $type); $this->stopwatch->start($title, 'Jarves'); $typeRenderer = $this->getTypeRenderer($type); if (!$typeRenderer) { $this->stopwatch->stop($title); throw new TypeNotFoundException(sprintf('Type renderer for `%s` not found. [%s] %s', $type, json_encode($content), json_encode(array_keys($this->types)))); } $typeRenderer->setContent($content); $typeRenderer->setParameters($parameters); $html = $typeRenderer->render(); $data['content'] = $content->toArray(TableMap::TYPE_CAMELNAME); $data['parameter'] = $parameters; $data['html'] = $html; $this->eventDispatcher->dispatch('core/render/content/pre', new GenericEvent($data)); $unsearchable = false; if (!is_array($content->getAccessFromGroups()) && $content->getAccessFromGroups() != '' || is_array($content->getAccessFromGroups()) && count($content->getAccessFromGroups()) > 0 || $content->getAccessFrom() > 0 && $content->getAccessFrom() > time() || $content->getAccessTo() > 0 && $content->getAccessTo() < time() || $content->getUnsearchable()) { $unsearchable = true; } if ($html) { if ($content->getTemplate() == '' || $content->getTemplate() == '-') { if ($unsearchable && $data['html']) { $result = '<!--unsearchable-begin-->' . $data['html'] . '<!--unsearchable-end-->'; } else { $result = $data['html']; } } else { $result = $this->templating->render($content->getTemplate(), $data); if ($unsearchable && $result) { $result = '<!--unsearchable-begin-->' . $result . '<!--unsearchable-end-->'; } } } $argument = array(&$result, $data); $this->eventDispatcher->dispatch('core/render/content', new GenericEvent($argument)); $this->stopwatch->stop($title); return $result; }
/** * @return string */ public function getContentValue() { return $this->content->getContent(); }