layoutFactory = $layoutFactory; $this->resultRawFactory = $resultRawFactory; parent::__construct($context); } /** * Chooser Source action * * @return \Magento\Framework\Controller\Result\Raw */ public function execute() { $uniqId = $this->getRequest()->getParam('uniq_id'); /** @var \Magento\Framework\View\Layout $layout */ $layout = $this->layoutFactory->create(); $pagesGrid = $layout->createBlock( \Magento\Cms\Block\Adminhtml\Page\Widget\Chooser::class, '', ['data' => ['id' => $uniqId]] ); $html = $pagesGrid->toHtml(); /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */ $resultRaw = $this->resultRawFactory->create(); return $resultRaw->setContents($html); } }