Networking\InitCmsBundle\Twig\Extension\NetworkingHelperExtension::renderInitCmsBlock PHP Метод

renderInitCmsBlock() публичный Метод

Returns an HTML block for output in the frontend
public renderInitCmsBlock ( $template, Networking\InitCmsBundle\Model\LayoutBlockInterface $layoutBlock, array $params = [] ) : string
$template
$layoutBlock Networking\InitCmsBundle\Model\LayoutBlockInterface
$params array
Результат string
    public function renderInitCmsBlock($template, LayoutBlockInterface $layoutBlock, $params = array())
    {
        /** @var \Sonata\AdminBundle\Admin\AdminInterface $layoutBlockAdmin */
        $layoutBlockAdmin = $this->getService('networking_init_cms.admin.layout_block');
        if (!($serializedContent = $layoutBlock->getSnapshotContent())) {
            // Draft View
            $contentItem = $layoutBlock->getContent();
        } else {
            // Live View
            $contentItem = $this->getService('serializer')->deserialize($serializedContent, $layoutBlock->getClassType(), 'json');
        }
        if (!is_object($contentItem)) {
            $layoutBlockAdmin->delete($layoutBlock);
            return '---';
        }
        $options = $contentItem->getTemplateOptions($params);
        $options = array_merge($options, $params);
        return $this->getService('templating')->render($template, $options);
    }