Skip to content

Commit 1e07346

Browse files
authored
ENGCOM-5909: Replaced usage of ObjectManager with Constructor DI of Factory class #24661
2 parents 5ca2e4a + 08b42b6 commit 1e07346

File tree

1 file changed

+21
-12
lines changed
  • app/code/Magento/Catalog/Controller/Adminhtml/Category

1 file changed

+21
-12
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Category/Add.php

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,41 @@
66
*/
77
namespace Magento\Catalog\Controller\Adminhtml\Category;
88

9-
use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
9+
use Magento\Backend\App\Action\Context;
10+
use Magento\Backend\Model\View\Result\Page;
11+
use Magento\Framework\Controller\ResultFactory;
12+
use Magento\Backend\Model\View\Result\Redirect;
13+
use Magento\Framework\Controller\ResultInterface;
14+
use Magento\Catalog\Controller\Adminhtml\Category;
15+
use Magento\Backend\Model\View\Result\ForwardFactory;
16+
use Magento\Framework\App\Action\HttpGetActionInterface;
1017

1118
/**
1219
* Class Add Category
1320
*
1421
* @package Magento\Catalog\Controller\Adminhtml\Category
1522
*/
16-
class Add extends \Magento\Catalog\Controller\Adminhtml\Category implements HttpGetActionInterface
23+
class Add extends Category implements HttpGetActionInterface
1724
{
1825
/**
1926
* Forward factory for result
2027
*
21-
* @var \Magento\Backend\Model\View\Result\ForwardFactory
28+
* @deprecated Unused Class: ForwardFactory
29+
* @see $this->resultFactory->create()
30+
* @var ForwardFactory
31+
*
2232
*/
2333
protected $resultForwardFactory;
2434

2535
/**
2636
* Add category constructor
2737
*
28-
* @param \Magento\Backend\App\Action\Context $context
29-
* @param \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory
38+
* @param Context $context
39+
* @param ForwardFactory $resultForwardFactory
3040
*/
3141
public function __construct(
32-
\Magento\Backend\App\Action\Context $context,
33-
\Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory
42+
Context $context,
43+
ForwardFactory $resultForwardFactory
3444
) {
3545
parent::__construct($context);
3646
$this->resultForwardFactory = $resultForwardFactory;
@@ -39,15 +49,15 @@ public function __construct(
3949
/**
4050
* Add new category form
4151
*
42-
* @return \Magento\Backend\Model\View\Result\Forward
52+
* @return ResultInterface
4353
*/
4454
public function execute()
4555
{
4656
$parentId = (int)$this->getRequest()->getParam('parent');
4757

4858
$category = $this->_initCategory(true);
4959
if (!$category || !$parentId || $category->getId()) {
50-
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
60+
/** @var Redirect $resultRedirect */
5161
$resultRedirect = $this->resultRedirectFactory->create();
5262
return $resultRedirect->setPath('catalog/*/', ['_current' => true, 'id' => null]);
5363
}
@@ -61,9 +71,8 @@ public function execute()
6171
$category->addData($categoryData);
6272
}
6373

64-
$resultPageFactory = $this->_objectManager->get(\Magento\Framework\View\Result\PageFactory::class);
65-
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
66-
$resultPage = $resultPageFactory->create();
74+
/** @var Page $resultPage */
75+
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
6776

6877
if ($this->getRequest()->getQuery('isAjax')) {
6978
return $this->ajaxRequestResponse($category, $resultPage);

0 commit comments

Comments
 (0)