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\Model\FaqGroup; |
||
23 | |||
24 | use Magento\Framework\App\Request\DataPersistorInterface; |
||
0 ignored issues
–
show
|
|||
25 | use Magento\Framework\Exception\NoSuchEntityException; |
||
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
26 | use Magento\Store\Model\StoreManagerInterface; |
||
0 ignored issues
–
show
The type
Magento\Store\Model\StoreManagerInterface 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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
27 | use Magento\Ui\DataProvider\AbstractDataProvider; |
||
0 ignored issues
–
show
The type
Magento\Ui\DataProvider\AbstractDataProvider 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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
28 | use Mageprince\Faq\Model\ResourceModel\FaqGroup\CollectionFactory; |
||
0 ignored issues
–
show
The type
Mageprince\Faq\Model\Res...Group\CollectionFactory 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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
29 | |||
30 | class DataProvider extends AbstractDataProvider |
||
31 | { |
||
32 | /** |
||
33 | * @var array |
||
34 | */ |
||
35 | private $loadedData; |
||
36 | |||
37 | /** |
||
38 | * @var DataPersistorInterface |
||
39 | */ |
||
40 | private $dataPersistor; |
||
41 | |||
42 | /** |
||
43 | * @var CollectionFactory |
||
44 | */ |
||
45 | public $collection; |
||
46 | |||
47 | /** |
||
48 | * @var StoreManagerInterface |
||
49 | */ |
||
50 | protected $storeManager; |
||
51 | |||
52 | /** |
||
53 | * DataProvider constructor. |
||
54 | * |
||
55 | * @param string $name |
||
56 | * @param string $primaryFieldName |
||
57 | * @param string $requestFieldName |
||
58 | * @param CollectionFactory $collectionFactory |
||
59 | * @param DataPersistorInterface $dataPersistor |
||
60 | * @param StoreManagerInterface $storeManager |
||
61 | * @param array $meta |
||
62 | * @param array $data |
||
63 | */ |
||
64 | public function __construct( |
||
65 | $name, |
||
66 | $primaryFieldName, |
||
67 | $requestFieldName, |
||
68 | CollectionFactory $collectionFactory, |
||
69 | DataPersistorInterface $dataPersistor, |
||
70 | StoreManagerInterface $storeManager, |
||
71 | array $meta = [], |
||
72 | array $data = [] |
||
73 | ) { |
||
74 | $this->collection = $collectionFactory->create(); |
||
75 | $this->dataPersistor = $dataPersistor; |
||
76 | $this->storeManager = $storeManager; |
||
77 | parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data); |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * Get data |
||
82 | * |
||
83 | * @return array |
||
84 | * @throws NoSuchEntityException |
||
85 | */ |
||
86 | public function getData() |
||
87 | { |
||
88 | if (isset($this->loadedData)) { |
||
89 | return $this->loadedData; |
||
90 | } |
||
91 | |||
92 | $items = $this->collection->getItems(); |
||
93 | |||
94 | foreach ($items as $model) { |
||
95 | $this->loadedData[$model->getId()] = $model->getData(); |
||
96 | if ($model->getIcon()) { |
||
97 | $m['icon'][0]['name'] = $model->getIcon(); |
||
98 | $m['icon'][0]['url'] = $this->getMediaUrl() . $model->getIcon(); |
||
99 | $fullData = $this->loadedData; |
||
100 | $this->loadedData[$model->getId()] = array_merge($fullData[$model->getId()], $m); |
||
101 | } |
||
102 | } |
||
103 | |||
104 | $data = $this->dataPersistor->get('prince_faq_faqgroup'); |
||
105 | |||
106 | if (!empty($data)) { |
||
107 | $model = $this->collection->getNewEmptyItem(); |
||
108 | $model->setData($data); |
||
109 | $this->loadedData[$model->getId()] = $model->getData(); |
||
110 | $this->dataPersistor->clear('prince_faq_faqgroup'); |
||
111 | } |
||
112 | |||
113 | return $this->loadedData; |
||
114 | } |
||
115 | |||
116 | /** |
||
117 | * Get media url |
||
118 | * |
||
119 | * @return string |
||
120 | * @throws NoSuchEntityException |
||
121 | */ |
||
122 | public function getMediaUrl() |
||
123 | { |
||
124 | $mediaUrl = $this->storeManager->getStore() |
||
125 | ->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . 'faq/tmp/icon/'; |
||
0 ignored issues
–
show
The type
Magento\Framework\UrlInterface 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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
126 | return $mediaUrl; |
||
127 | } |
||
128 | } |
||
129 |
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