Skip to content

Instantly share code, notes, and snippets.

@andrewdaluz
Last active September 10, 2020 20:34
Show Gist options
  • Save andrewdaluz/1175dfe6e5ee5ea3631b7358c62b7131 to your computer and use it in GitHub Desktop.
Save andrewdaluz/1175dfe6e5ee5ea3631b7358c62b7131 to your computer and use it in GitHub Desktop.
namespace Vendor\Module\Helper;
class Data extends \Magento\Framework\App\Helper\AbstractHelper
{
/**
* @var \Magento\Framework\View\LayoutInterface
*/
protected $layout;
/**
* Data constructor.
* @param \Magento\Framework\App\Helper\Context $context
* @param \Magento\Framework\View\LayoutInterface $layout
*/
public function __construct(
\Magento\Framework\App\Helper\Context $context,
\Magento\Framework\View\LayoutInterface $layout
) {
$this->layout = $layout;
parent::__construct($context);
}
/**
* @return block $valueContent
*/
public function getBlock() {
$valueContent = $this->layout
->createBlock('Magento\Cms\Block\Block')
->setBlockId('my_identifier')
->toHtml();
return $valueContent;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment