/** * Executes the block as specified in the content. * * @param array $block An array including the block name * * @return string the rendered block */ protected function embeddedRender($block) { try { return $this->sonataBlock->render(array('name' => trim($block[1]))); } catch (\Exception $e) { if ($this->logger) { $this->logger->warn('Failed to render block "' . $block[1] . '" embedded in content: ' . $e->getTraceAsString()); } } return ''; }
/** * Executes the block as specified in the content. * * @param $name * * @return string */ protected function embeddedRender($name) { $name = trim($name); try { return $this->sonataBlock->render(['name' => $name]); } catch (\Exception $e) { if ($this->logger) { $this->logger->warning(sprintf('Failed to render block "%s" embedded in content: %s', $name, $e->getTraceAsString())); } } return ''; }
/** * @param PageBlockInterface $block * @param array $options * * @return string */ public function renderBlock(PageBlockInterface $block, array $options = array()) { if ($block->getEnabled() === false && !$this->cmsManagerSelector->isEditor()) { return ''; } // defined extra default key for the cache $pageCacheKeys = array('manager' => $block->getPage() instanceof SnapshotPageProxy ? 'snapshot' : 'page', 'page_id' => $block->getPage()->getId()); // build the parameters array $options = array_merge(array('use_cache' => isset($options['use_cache']) ? $options['use_cache'] : true, 'extra_cache_keys' => array()), $pageCacheKeys, $options); // make sure the parameters array contains all valid keys $options['extra_cache_keys'] = array_merge($options['extra_cache_keys'], $pageCacheKeys); return $this->blockHelper->render($block, $options); }