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\Index; |
||
23 | |||
24 | use Magento\Framework\App\Action; |
||
0 ignored issues
–
show
|
|||
25 | use Magento\Framework\App\Cache\Type\Block as TypeBlock; |
||
0 ignored issues
–
show
The type
Magento\Framework\App\Cache\Type\Block 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\Framework\App\CacheInterface; |
||
0 ignored issues
–
show
The type
Magento\Framework\App\CacheInterface 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\Framework\Controller\Result\JsonFactory; |
||
0 ignored issues
–
show
The type
Magento\Framework\Controller\Result\JsonFactory 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 Magento\Framework\Controller\ResultInterface; |
||
0 ignored issues
–
show
The type
Magento\Framework\Controller\ResultInterface 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 | 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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
30 | use Mageprince\Faq\Block\Index\Index as FaqBlock; |
||
31 | use Mageprince\Faq\Helper\Data; |
||
32 | use Mageprince\Faq\Model\Config\DefaultConfig; |
||
33 | |||
34 | class Ajax extends Action\Action |
||
0 ignored issues
–
show
The type
Magento\Framework\App\Action\Action 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 ![]() |
|||
35 | { |
||
36 | /** |
||
37 | * Cache key |
||
38 | */ |
||
39 | private const FAQ_GROUP_CACHE_KEY = 'mageprince_faq_group_'; |
||
40 | |||
41 | /** |
||
42 | * @var PageFactory |
||
43 | */ |
||
44 | protected $resultPageFactory; |
||
45 | |||
46 | /** |
||
47 | * @var JsonFactory |
||
48 | */ |
||
49 | protected $resultJsonFactory; |
||
50 | |||
51 | /** |
||
52 | * @var Data |
||
53 | */ |
||
54 | protected $helper; |
||
55 | |||
56 | /** |
||
57 | * @var CacheInterface |
||
58 | */ |
||
59 | protected $cache; |
||
60 | |||
61 | /** |
||
62 | * Ajax constructor. |
||
63 | * @param Action\Context $context |
||
64 | * @param Data $helper |
||
65 | * @param PageFactory $resultPageFactory |
||
66 | * @param JsonFactory $resultJsonFactory |
||
67 | * @param CacheInterface $cache |
||
68 | */ |
||
69 | public function __construct( |
||
70 | Action\Context $context, |
||
0 ignored issues
–
show
The type
Magento\Framework\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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
71 | Data $helper, |
||
72 | PageFactory $resultPageFactory, |
||
73 | JsonFactory $resultJsonFactory, |
||
74 | CacheInterface $cache |
||
75 | ) { |
||
76 | $this->helper = $helper; |
||
77 | $this->resultPageFactory = $resultPageFactory; |
||
78 | $this->resultJsonFactory = $resultJsonFactory; |
||
79 | parent::__construct($context); |
||
80 | $this->cache = $cache; |
||
81 | } |
||
82 | |||
83 | /** |
||
84 | * Ajax request |
||
85 | * |
||
86 | * @return ResultInterface|void |
||
87 | */ |
||
88 | public function execute() |
||
89 | { |
||
90 | if ($this->getRequest()->isXmlHttpRequest()) { |
||
91 | $groupId = $this->getRequest()->getParam('groupId'); |
||
92 | $faqHtml = $this->getFaqHtml($groupId); |
||
93 | $resultJson = $this->resultJsonFactory->create(); |
||
94 | $resultJson->setData(['faq' => $faqHtml]); |
||
95 | return $resultJson; |
||
96 | } |
||
97 | } |
||
98 | |||
99 | /** |
||
100 | * Get faq html from cache |
||
101 | * |
||
102 | * @param int $groupId |
||
103 | * @return string |
||
104 | */ |
||
105 | protected function getFaqHtml($groupId) |
||
106 | { |
||
107 | $faqHtml = $this->cache->load($this->getCacheKey($groupId)); |
||
108 | if (false === $faqHtml) { |
||
109 | $resultPage = $this->resultPageFactory->create(); |
||
110 | $faqHtml = $resultPage->getLayout() |
||
111 | ->createBlock(FaqBlock::class) |
||
112 | ->setTemplate(DefaultConfig::FAQ_AJAX_TEMPLATE_FILE) |
||
113 | ->setGroupId($groupId) |
||
114 | ->toHtml(); |
||
115 | |||
116 | $this->cache->save( |
||
117 | $faqHtml, |
||
118 | $this->getCacheKey($groupId), |
||
119 | [ |
||
120 | TypeBlock::TYPE_IDENTIFIER |
||
121 | ] |
||
122 | ); |
||
123 | } |
||
124 | return $faqHtml; |
||
125 | } |
||
126 | |||
127 | /** |
||
128 | * Retrieve cache key |
||
129 | * |
||
130 | * @param int $groupId |
||
131 | * @return string |
||
132 | */ |
||
133 | protected function getCacheKey($groupId) |
||
134 | { |
||
135 | return self::FAQ_GROUP_CACHE_KEY . $groupId; |
||
136 | } |
||
137 | } |
||
138 |
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