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; |
|
|
|
|
25
|
|
|
use Magento\Framework\Controller\Result\Json; |
|
|
|
|
26
|
|
|
use Magento\Framework\Controller\Result\JsonFactory; |
|
|
|
|
27
|
|
|
use Magento\Framework\Controller\ResultInterface; |
|
|
|
|
28
|
|
|
use Mageprince\Faq\Model\FaqRepository; |
29
|
|
|
|
30
|
|
|
class InlineEdit extends Action |
31
|
|
|
{ |
32
|
|
|
/** |
33
|
|
|
* @var JsonFactory |
34
|
|
|
*/ |
35
|
|
|
protected $jsonFactory; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var FaqRepository |
39
|
|
|
*/ |
40
|
|
|
protected $faqRepository; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* InlineEdit constructor. |
44
|
|
|
* @param Action\Context $context |
45
|
|
|
* @param JsonFactory $jsonFactory |
46
|
|
|
* @param FaqRepository $faqRepository |
47
|
|
|
*/ |
48
|
|
|
public function __construct( |
49
|
|
|
Action\Context $context, |
|
|
|
|
50
|
|
|
JsonFactory $jsonFactory, |
51
|
|
|
FaqRepository $faqRepository |
52
|
|
|
) { |
53
|
|
|
$this->jsonFactory = $jsonFactory; |
54
|
|
|
$this->faqRepository = $faqRepository; |
55
|
|
|
parent::__construct($context); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @inheritdoc |
60
|
|
|
*/ |
61
|
|
|
public function _isAllowed() |
62
|
|
|
{ |
63
|
|
|
return $this->_authorization->isAllowed('Mageprince_Faq::Faq'); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Inline edit action |
68
|
|
|
* |
69
|
|
|
* @return ResultInterface |
70
|
|
|
*/ |
71
|
|
|
public function execute() |
72
|
|
|
{ |
73
|
|
|
/** @var Json $resultJson */ |
74
|
|
|
$resultJson = $this->jsonFactory->create(); |
75
|
|
|
$error = false; |
76
|
|
|
$messages = []; |
77
|
|
|
|
78
|
|
|
if ($this->getRequest()->getParam('isAjax')) { |
79
|
|
|
$postItems = $this->getRequest()->getParam('items', []); |
80
|
|
|
if (empty($postItems)) { |
81
|
|
|
$messages[] = __('Please correct the data sent.'); |
|
|
|
|
82
|
|
|
$error = true; |
83
|
|
|
} else { |
84
|
|
|
foreach (array_keys($postItems) as $faqId) { |
85
|
|
|
try { |
86
|
|
|
$model = $this->faqRepository->getById($faqId); |
87
|
|
|
$model->setData(array_merge($model->getData(), $postItems[$faqId])); |
|
|
|
|
88
|
|
|
$this->faqRepository->save($model); |
89
|
|
|
} catch (\Exception $e) { |
90
|
|
|
$messages[] = "[Faq ID: {$faqId}] {$e->getMessage()}"; |
91
|
|
|
$error = true; |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
return $resultJson->setData([ |
98
|
|
|
'messages' => $messages, |
99
|
|
|
'error' => $error |
100
|
|
|
]); |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths