Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
RefreshPath.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
10 
12 {
16  protected $resultJsonFactory;
17 
22  public function __construct(
23  \Magento\Backend\App\Action\Context $context,
24  \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
25  ) {
26  parent::__construct($context);
27  $this->resultJsonFactory = $resultJsonFactory;
28  }
29 
35  public function execute()
36  {
37  $categoryId = (int)$this->getRequest()->getParam('id');
38  if ($categoryId) {
39  $category = $this->_objectManager->create(\Magento\Catalog\Model\Category::class)->load($categoryId);
40 
42  $resultJson = $this->resultJsonFactory->create();
43  return $resultJson->setData([
44  'id' => $categoryId,
45  'path' => $category->getPath(),
46  'parentId' => $category->getParentId(),
47  ]);
48  }
49  }
50 }
__construct(\Magento\Backend\App\Action\Context $context, \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory)
Definition: RefreshPath.php:22