Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
BuildWidget.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
10 
11 class BuildWidget extends \Magento\Backend\App\Action implements HttpPostActionInterface
12 {
16  const ADMIN_RESOURCE = 'Magento_Widget::widget_instance';
17 
21  protected $_widget;
22 
27  public function __construct(
28  \Magento\Backend\App\Action\Context $context,
29  \Magento\Widget\Model\Widget $widget
30  ) {
31  $this->_widget = $widget;
32  parent::__construct($context);
33  }
34 
40  public function execute()
41  {
42  $type = $this->getRequest()->getPost('widget_type');
43  $params = $this->getRequest()->getPost('parameters', []);
44  $asIs = $this->getRequest()->getPost('as_is');
45  $html = $this->_widget->getWidgetDeclaration($type, $params, $asIs);
46  $this->getResponse()->setBody($html);
47  }
48 }
__construct(\Magento\Backend\App\Action\Context $context, \Magento\Widget\Model\Widget $widget)
Definition: BuildWidget.php:27
$type
Definition: item.phtml:13
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18