|
6 | 6 | */
|
7 | 7 | namespace Magento\Catalog\Controller\Adminhtml\Product\Set;
|
8 | 8 |
|
9 |
| -use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface; |
| 9 | +use Magento\Framework\Registry; |
| 10 | +use Magento\Backend\App\Action\Context; |
| 11 | +use Magento\Framework\App\ObjectManager; |
| 12 | +use Magento\Backend\Model\View\Result\Page; |
| 13 | +use Magento\Framework\View\Result\PageFactory; |
| 14 | +use Magento\Framework\Controller\ResultInterface; |
| 15 | +use Magento\Eav\Api\AttributeSetRepositoryInterface; |
| 16 | +use Magento\Catalog\Controller\Adminhtml\Product\Set; |
| 17 | +use Magento\Framework\Exception\NoSuchEntityException; |
| 18 | +use Magento\Framework\App\Action\HttpGetActionInterface; |
10 | 19 |
|
11 |
| -class Edit extends \Magento\Catalog\Controller\Adminhtml\Product\Set implements HttpGetActionInterface |
| 20 | +/** |
| 21 | + * Edit attribute set controller. |
| 22 | + */ |
| 23 | +class Edit extends Set implements HttpGetActionInterface |
12 | 24 | {
|
13 | 25 | /**
|
14 |
| - * @var \Magento\Framework\View\Result\PageFactory |
| 26 | + * @var PageFactory |
15 | 27 | */
|
16 | 28 | protected $resultPageFactory;
|
17 | 29 |
|
18 | 30 | /**
|
19 |
| - * @param \Magento\Backend\App\Action\Context $context |
20 |
| - * @param \Magento\Framework\Registry $coreRegistry |
21 |
| - * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory |
| 31 | + * @var AttributeSetRepositoryInterface |
| 32 | + */ |
| 33 | + private $attributeSetRepository; |
| 34 | + |
| 35 | + /** |
| 36 | + * @param Context $context |
| 37 | + * @param Registry $coreRegistry |
| 38 | + * @param PageFactory $resultPageFactory |
| 39 | + * @param AttributeSetRepositoryInterface $attributeSetRepository |
22 | 40 | */
|
23 | 41 | public function __construct(
|
24 |
| - \Magento\Backend\App\Action\Context $context, |
25 |
| - \Magento\Framework\Registry $coreRegistry, |
26 |
| - \Magento\Framework\View\Result\PageFactory $resultPageFactory |
| 42 | + Context $context, |
| 43 | + Registry $coreRegistry, |
| 44 | + PageFactory $resultPageFactory, |
| 45 | + AttributeSetRepositoryInterface $attributeSetRepository = null |
27 | 46 | ) {
|
28 | 47 | parent::__construct($context, $coreRegistry);
|
29 | 48 | $this->resultPageFactory = $resultPageFactory;
|
| 49 | + $this->attributeSetRepository = $attributeSetRepository ?: |
| 50 | + ObjectManager::getInstance()->get(AttributeSetRepositoryInterface::class); |
30 | 51 | }
|
31 | 52 |
|
32 | 53 | /**
|
33 |
| - * @return \Magento\Backend\Model\View\Result\Page |
| 54 | + * @inheritdoc |
34 | 55 | */
|
35 | 56 | public function execute()
|
36 | 57 | {
|
37 | 58 | $this->_setTypeId();
|
38 |
| - $attributeSet = $this->_objectManager->create(\Magento\Eav\Model\Entity\Attribute\Set::class) |
39 |
| - ->load($this->getRequest()->getParam('id')); |
40 |
| - |
| 59 | + $attributeSet = $this->attributeSetRepository->get($this->getRequest()->getParam('id')); |
41 | 60 | if (!$attributeSet->getId()) {
|
42 | 61 | return $this->resultRedirectFactory->create()->setPath('catalog/*/index');
|
43 | 62 | }
|
44 |
| - |
45 | 63 | $this->_coreRegistry->register('current_attribute_set', $attributeSet);
|
46 | 64 |
|
47 |
| - /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ |
| 65 | + /** @var Page $resultPage */ |
48 | 66 | $resultPage = $this->resultPageFactory->create();
|
49 | 67 | $resultPage->setActiveMenu('Magento_Catalog::catalog_attributes_sets');
|
50 | 68 | $resultPage->getConfig()->getTitle()->prepend(__('Attribute Sets'));
|
|
0 commit comments