Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Contents.php
Go to the documentation of this file.
1 <?php
8 
10 {
15 
19  protected $resultJsonFactory;
20 
27  public function __construct(
28  \Magento\Backend\App\Action\Context $context,
29  \Magento\Framework\Registry $coreRegistry,
30  \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory,
31  \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
32  ) {
33  $this->resultLayoutFactory = $resultLayoutFactory;
34  $this->resultJsonFactory = $resultJsonFactory;
35  parent::__construct($context, $coreRegistry);
36  }
37 
43  protected function _saveSessionCurrentPath()
44  {
45  $this->getStorage()->getSession()->setCurrentPath(
46  $this->_objectManager->get(\Magento\Cms\Helper\Wysiwyg\Images::class)->getCurrentPath()
47  );
48  return $this;
49  }
50 
56  public function execute()
57  {
58  try {
59  $this->_initAction()->_saveSessionCurrentPath();
61  $resultLayout = $this->resultLayoutFactory->create();
62  return $resultLayout;
63  } catch (\Exception $e) {
64  $result = ['error' => true, 'message' => $e->getMessage()];
66  $resultJson = $this->resultJsonFactory->create();
67  $resultJson->setData($result);
68  return $resultJson;
69  }
70  }
71 }
__construct(\Magento\Backend\App\Action\Context $context, \Magento\Framework\Registry $coreRegistry, \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory, \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory)
Definition: Contents.php:27