Issues (254)

Controller/Adminhtml/Faq/Edit.php (5 issues)

Labels
Severity
1
<?php
2
/**
3
 * MagePrince
4
 *
5
 * NOTICE OF LICENSE
6
 *
7
 * This source file is subject to the mageprince.com license that is
8
 * available through the world-wide-web at this URL:
9
 * https://mageprince.com/end-user-license-agreement
10
 *
11
 * DISCLAIMER
12
 *
13
 * Do not edit or add to this file if you wish to upgrade this extension to newer
14
 * version in the future.
15
 *
16
 * @category    MagePrince
17
 * @package     Mageprince_Faq
18
 * @copyright   Copyright (c) MagePrince (https://mageprince.com/)
19
 * @license     https://mageprince.com/end-user-license-agreement
20
 */
21
22
namespace Mageprince\Faq\Controller\Adminhtml\Faq;
23
24
use Magento\Backend\App\Action\Context;
0 ignored issues
show
The type Magento\Backend\App\Action\Context was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
25
use Magento\Framework\Controller\ResultFactory;
0 ignored issues
show
The type Magento\Framework\Controller\ResultFactory was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
26
use Magento\Framework\View\Result\PageFactory;
0 ignored issues
show
The type Magento\Framework\View\Result\PageFactory was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
27
use Mageprince\Faq\Model\FaqRepository;
28
29
class Edit extends Faq
30
{
31
    /**
32
     * @var PageFactory
33
     */
34
    protected $resultPageFactory;
35
36
    /**
37
     * @var FaqRepository
38
     */
39
    protected $faqRepository;
40
41
    /**
42
     * Edit constructor.
43
     * @param Context $context
44
     * @param PageFactory $resultPageFactory
45
     * @param FaqRepository $faqRepository
46
     */
47
    public function __construct(
48
        Context $context,
49
        PageFactory $resultPageFactory,
50
        FaqRepository $faqRepository
51
    ) {
52
        $this->resultPageFactory = $resultPageFactory;
53
        $this->faqRepository = $faqRepository;
54
        parent::__construct($context);
55
    }
56
57
    public function execute()
58
    {
59
        /** @var \Magento\Backend\Model\View\Result\Page $resultPage */
60
        $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
61
        $resultPage->setActiveMenu('Mageprince_Faq::menu');
62
63
        if ($faqGroupId = (int) $this->getRequest()->getParam('faq_id')) {
64
            try {
65
                $faq = $this->faqRepository->getById($faqGroupId);
66
                $resultPage->getConfig()->getTitle()->prepend(__($faq->getTitle()));
0 ignored issues
show
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

66
                $resultPage->getConfig()->getTitle()->prepend(/** @scrutinizer ignore-call */ __($faq->getTitle()));
Loading history...
67
            } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
0 ignored issues
show
The type Magento\Framework\Exception\NoSuchEntityException was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
68
                $this->messageManager->addErrorMessage(__('This FAQ no longer exists.'));
69
70
                return $this->_redirect('*/*/index');
71
            }
72
        } else {
73
            $resultPage->getConfig()->getTitle()->prepend(__('New FAQ'));
74
        }
75
76
        return $resultPage;
77
    }
78
}
79