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