Example #1
0
 /**
  * Build response for ajax request
  *
  * @param \Magento\Catalog\Model\Category $category
  * @param \Magento\Backend\Model\View\Result\Page $resultPage
  *
  * @return \Magento\Framework\Controller\Result\Json
  *
  * @deprecated
  */
 protected function ajaxRequestResponse($category, $resultPage)
 {
     // prepare breadcrumbs of selected category, if any
     $breadcrumbsPath = $category->getPath();
     if (empty($breadcrumbsPath)) {
         // but if no category, and it is deleted - prepare breadcrumbs from path, saved in session
         $breadcrumbsPath = $this->_objectManager->get('Magento\\Backend\\Model\\Auth\\Session')->getDeletedPath(true);
         if (!empty($breadcrumbsPath)) {
             $breadcrumbsPath = explode('/', $breadcrumbsPath);
             // no need to get parent breadcrumbs if deleting category level 1
             if (count($breadcrumbsPath) <= 1) {
                 $breadcrumbsPath = '';
             } else {
                 array_pop($breadcrumbsPath);
                 $breadcrumbsPath = implode('/', $breadcrumbsPath);
             }
         }
     }
     $eventResponse = new \Magento\Framework\DataObject(['content' => $resultPage->getLayout()->getUiComponent('category_form')->getFormHtml() . $resultPage->getLayout()->getBlock('category.tree')->getBreadcrumbsJavascript($breadcrumbsPath, 'editingCategoryBreadcrumbs'), 'messages' => $resultPage->getLayout()->getMessagesBlock()->getGroupedHtml(), 'toolbar' => $resultPage->getLayout()->getBlock('page.actions.toolbar')->toHtml()]);
     $this->_eventManager->dispatch('category_prepare_ajax_response', ['response' => $eventResponse, 'controller' => $this]);
     /** @var \Magento\Framework\Controller\Result\Json $resultJson */
     $resultJson = $this->_objectManager->get('Magento\\Framework\\Controller\\Result\\Json');
     $resultJson->setHeader('Content-type', 'application/json', true);
     $resultJson->setData($eventResponse->getData());
     return $resultJson;
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function getLayout()
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getLayout');
     if (!$pluginInfo) {
         return parent::getLayout();
     } else {
         return $this->___callPlugins('getLayout', func_get_args(), $pluginInfo);
     }
 }