Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions app/code/Magento/Catalog/Controller/Adminhtml/Category/Add.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,41 @@
*/
namespace Magento\Catalog\Controller\Adminhtml\Category;

use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Backend\App\Action\Context;
use Magento\Backend\Model\View\Result\Page;
use Magento\Framework\Controller\ResultFactory;
use Magento\Backend\Model\View\Result\Redirect;
use Magento\Framework\Controller\ResultInterface;
use Magento\Catalog\Controller\Adminhtml\Category;
use Magento\Backend\Model\View\Result\ForwardFactory;
use Magento\Framework\App\Action\HttpGetActionInterface;

/**
* Class Add Category
*
* @package Magento\Catalog\Controller\Adminhtml\Category
*/
class Add extends \Magento\Catalog\Controller\Adminhtml\Category implements HttpGetActionInterface
class Add extends Category implements HttpGetActionInterface
{
/**
* Forward factory for result
*
* @var \Magento\Backend\Model\View\Result\ForwardFactory
* @deprecated Unused Class: ForwardFactory
* @see $this->resultFactory->create()
* @var ForwardFactory
*
*/
protected $resultForwardFactory;

/**
* Add category constructor
*
* @param \Magento\Backend\App\Action\Context $context
* @param \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory
* @param Context $context
* @param ForwardFactory $resultForwardFactory
*/
public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory
Context $context,
ForwardFactory $resultForwardFactory
) {
parent::__construct($context);
$this->resultForwardFactory = $resultForwardFactory;
Expand All @@ -39,15 +49,15 @@ public function __construct(
/**
* Add new category form
*
* @return \Magento\Backend\Model\View\Result\Forward
* @return ResultInterface
*/
public function execute()
{
$parentId = (int)$this->getRequest()->getParam('parent');

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

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

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