|
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\Ui\Component\MassAction\Filter; |
|
|
|
|
|
|
26
|
|
|
use Mageprince\Faq\Model\ResourceModel\Faq\CollectionFactory; |
|
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
class MassDelete extends Faq |
|
29
|
|
|
{ |
|
30
|
|
|
/** |
|
31
|
|
|
* @var Filter |
|
32
|
|
|
*/ |
|
33
|
|
|
protected $filter; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @var CollectionFactory |
|
37
|
|
|
*/ |
|
38
|
|
|
protected $collectionFactory; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* MassDelete constructor. |
|
42
|
|
|
* @param Filter $filter |
|
43
|
|
|
* @param CollectionFactory $collectionFactory |
|
44
|
|
|
* @param Action\Context $context |
|
45
|
|
|
*/ |
|
46
|
|
|
public function __construct( |
|
47
|
|
|
Filter $filter, |
|
48
|
|
|
CollectionFactory $collectionFactory, |
|
49
|
|
|
Action\Context $context |
|
|
|
|
|
|
50
|
|
|
) { |
|
51
|
|
|
$this->filter = $filter; |
|
52
|
|
|
$this->collectionFactory = $collectionFactory; |
|
53
|
|
|
parent::__construct($context); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @inheritdoc |
|
58
|
|
|
*/ |
|
59
|
|
|
public function _isAllowed() |
|
60
|
|
|
{ |
|
61
|
|
|
return $this->_authorization->isAllowed('Mageprince_Faq::Faq'); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
public function execute() |
|
65
|
|
|
{ |
|
66
|
|
|
try { |
|
67
|
|
|
$logCollection = $this->filter->getCollection($this->collectionFactory->create()); |
|
68
|
|
|
$itemsDeleted = 0; |
|
69
|
|
|
foreach ($logCollection as $item) { |
|
70
|
|
|
$item->delete(); |
|
71
|
|
|
$itemsDeleted++; |
|
72
|
|
|
} |
|
73
|
|
|
$this->messageManager->addSuccessMessage(__('A total of %1 FAQ(s) were deleted.', $itemsDeleted)); |
|
|
|
|
|
|
74
|
|
|
} catch (\Exception $e) { |
|
75
|
|
|
$this->messageManager->addErrorMessage($e->getMessage()); |
|
76
|
|
|
} |
|
77
|
|
|
$resultRedirect = $this->resultRedirectFactory->create(); |
|
78
|
|
|
return $resultRedirect->setPath('mageprince_faq/faq'); |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|
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