Blocks.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\Widget\Controller\Adminhtml\Widget\Instance;
  8. class Blocks extends \Magento\Widget\Controller\Adminhtml\Widget\Instance
  9. {
  10. /**
  11. * Render page containers
  12. *
  13. * @return void
  14. */
  15. public function renderPageContainers()
  16. {
  17. /* @var $widgetInstance \Magento\Widget\Model\Widget\Instance */
  18. $widgetInstance = $this->_initWidgetInstance();
  19. $layout = $this->getRequest()->getParam('layout');
  20. $selected = $this->getRequest()->getParam('selected', null);
  21. $blocksChooser = $this->_view->getLayout()->createBlock(
  22. \Magento\Widget\Block\Adminhtml\Widget\Instance\Edit\Chooser\Container::class
  23. )->setValue(
  24. $selected
  25. )->setArea(
  26. $widgetInstance->getArea()
  27. )->setTheme(
  28. $widgetInstance->getThemeId()
  29. )->setLayoutHandle(
  30. $layout
  31. )->setAllowedContainers(
  32. $widgetInstance->getWidgetSupportedContainers()
  33. );
  34. $this->setBody($blocksChooser->toHtml());
  35. }
  36. /**
  37. * Blocks Action (Ajax request)
  38. *
  39. * @return void
  40. */
  41. public function execute()
  42. {
  43. $this->_objectManager->get(
  44. \Magento\Framework\App\State::class
  45. )->emulateAreaCode(
  46. 'frontend',
  47. [$this, 'renderPageContainers']
  48. );
  49. }
  50. }