blockFactory = $blockFactory; $this->filterProvider = $filterProvider; parent::__construct($context, $data); } /** * Get CMS block HTML content * * @return string */ public function getCmsBlockHtml() { $blockId = $this->getData('cms_block_id'); if (!$blockId) { return ''; } $block = $this->blockFactory->create(); $block->load($blockId, 'identifier'); if (!$block->getId() || !$block->isActive()) { return ''; } $html = $this->filterProvider->getBlockFilter() ->setStoreId($this->_storeManager->getStore()->getId()) ->filter($block->getContent()); return $html; } /** * Check if CMS block exists and is active * * @return bool */ public function hasCmsBlock() { $blockId = $this->getData('cms_block_id'); if (!$blockId) { return false; } $block = $this->blockFactory->create(); $block->load($blockId, 'identifier'); return $block->getId() && $block->isActive(); } }