Issues (104)

Controller/Adminhtml/Subseller/Save.php (4 issues)

1
<?php
2
/**
3
 * Copyright © Getnet. All rights reserved.
4
 *
5
 * @author    Bruno Elisei <[email protected]>
6
 * See LICENSE for license details.
7
 */
8
9
namespace Getnet\SubSellerMagento\Controller\Adminhtml\Subseller;
10
11
use Magento\Framework\Controller\ResultFactory;
12
use Magento\Framework\Exception\NoSuchEntityException;
13
14
class Save extends \Getnet\SubSellerMagento\Controller\Adminhtml\Subseller
15
{
16
    /**
17
     * Save Sub Seller and Data.
18
     *
19
     * @return \Magento\Backend\Model\View\Result\Redirect
20
     */
21
    public function execute()
22
    {
23
        /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
24
        $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
25
        $subSellerPost = $this->getRequest()->getPostValue();
0 ignored issues
show
The method getPostValue() does not exist on Magento\Framework\App\RequestInterface. It seems like you code against a sub-type of Magento\Framework\App\RequestInterface such as Magento\Framework\Webapi\Request or Magento\Framework\App\Request\Http. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
        $subSellerPost = $this->getRequest()->/** @scrutinizer ignore-call */ getPostValue();
Loading history...
26
        if ($subSellerPost) {
27
            $sellerId = $this->getRequest()->getParam('sellerid');
28
            if ($sellerId) {
29
                try {
30
                    $this->_subSellerRepository->get($sellerId);
31
                } catch (NoSuchEntityException $e) {
32
                    unset($subSellerPost['sellerid']);
33
                }
34
            }
35
36
            try {
37
                $subSellerData = $this->subSellerConverter->populateSubSellerData($subSellerPost);
38
                $this->_subSellerRepository->save($subSellerData);
39
40
                $this->messageManager->addSuccess(__('You saved the sub seller.'));
0 ignored issues
show
Deprecated Code introduced by
The function Magento\Framework\Messag...Interface::addSuccess() has been deprecated: 100.1.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

40
                /** @scrutinizer ignore-deprecated */ $this->messageManager->addSuccess(__('You saved the sub seller.'));

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
41
42
                return $resultRedirect->setPath('*/*/');
43
            } catch (\Magento\Framework\Exception\LocalizedException $e) {
44
                $this->_objectManager->get(\Magento\Backend\Model\Session::class)->setFormData($subSellerPost);
45
                $this->messageManager->addError($e->getMessage());
0 ignored issues
show
Deprecated Code introduced by
The function Magento\Framework\Messag...erInterface::addError() has been deprecated: 100.1.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

45
                /** @scrutinizer ignore-deprecated */ $this->messageManager->addError($e->getMessage());

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
46
            } catch (\Exception $e) {
47
                $this->messageManager->addError($e->getMessage());
0 ignored issues
show
Deprecated Code introduced by
The function Magento\Framework\Messag...erInterface::addError() has been deprecated: 100.1.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

47
                /** @scrutinizer ignore-deprecated */ $this->messageManager->addError($e->getMessage());

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
48
            }
49
50
            return $resultRedirect->setUrl($this->_redirect->getRedirectUrl($this->getUrl('*')));
51
        }
52
53
        return $resultRedirect->setPath('subseller/subseller');
54
    }
55
}
56