Chooser.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\Cms\Controller\Adminhtml\Block\Widget;
  8. use Magento\Backend\App\Action\Context;
  9. use Magento\Framework\View\LayoutFactory;
  10. use Magento\Framework\Controller\Result\RawFactory;
  11. class Chooser extends \Magento\Backend\App\Action
  12. {
  13. /**
  14. * Authorization level of a basic admin session
  15. */
  16. const ADMIN_RESOURCE = 'Magento_Widget::widget_instance';
  17. /**
  18. * @var \Magento\Framework\View\LayoutFactory
  19. */
  20. protected $layoutFactory;
  21. /**
  22. * @var RawFactory
  23. */
  24. protected $resultRawFactory;
  25. /**
  26. * @param Context $context
  27. * @param LayoutFactory $layoutFactory
  28. * @param RawFactory $resultRawFactory
  29. */
  30. public function __construct(Context $context, LayoutFactory $layoutFactory, RawFactory $resultRawFactory)
  31. {
  32. $this->layoutFactory = $layoutFactory;
  33. $this->resultRawFactory = $resultRawFactory;
  34. parent::__construct($context);
  35. }
  36. /**
  37. * Chooser Source action
  38. *
  39. * @return \Magento\Framework\Controller\ResultInterface
  40. */
  41. public function execute()
  42. {
  43. /** @var \Magento\Framework\View\Layout $layout */
  44. $layout = $this->layoutFactory->create();
  45. $uniqId = $this->getRequest()->getParam('uniq_id');
  46. $pagesGrid = $layout->createBlock(
  47. \Magento\Cms\Block\Adminhtml\Block\Widget\Chooser::class,
  48. '',
  49. ['data' => ['id' => $uniqId]]
  50. );
  51. /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
  52. $resultRaw = $this->resultRawFactory->create();
  53. $resultRaw->setContents($pagesGrid->toHtml());
  54. return $resultRaw;
  55. }
  56. }