88
99namespace Mygento \Base \Block ;
1010
11+ use Magento \Backend \Block \Context ;
12+ use Magento \Backend \Model \Auth \Session ;
13+ use Magento \Config \Block \System \Config \Form \Field ;
14+ use Magento \Config \Block \System \Config \Form \Fieldset ;
15+ use Magento \Framework \App \Config \ScopeConfigInterface ;
1116use Magento \Framework \Data \Form \Element \AbstractElement ;
17+ use Magento \Framework \Exception \FileSystemException ;
18+ use Magento \Framework \Filesystem \Driver \File ;
19+ use Magento \Framework \Module \Dir \Reader ;
20+ use Magento \Framework \Module \ModuleListInterface ;
21+ use Magento \Framework \Serialize \Serializer \Json ;
22+ use Magento \Framework \View \Element \BlockInterface ;
23+ use Magento \Framework \View \Helper \Js ;
24+ use Magento \Framework \View \LayoutFactory ;
1225
1326/**
1427 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1528 */
16- class Extensions extends \ Magento \ Config \ Block \ System \ Config \ Form \ Fieldset
29+ class Extensions extends Fieldset
1730{
18- /**
19- * @var \Magento\Framework\Module\ModuleListInterface
20- */
21- private $ moduleList ;
22-
23- /**
24- * @var \Magento\Framework\View\LayoutFactory
25- */
26- private $ layoutFactory ;
27-
28- /**
29- * @var \Magento\Framework\Module\Dir\Reader
30- */
31- private $ moduleReader ;
32-
33- /**
34- * @var \Magento\Framework\Json\DecoderInterface
35- */
36- private $ jsonDecoder ;
37-
38- /**
39- * @var \Magento\Framework\Filesystem\Driver\File
40- */
41- private $ filesystem ;
42-
43- /**
44- * @var \Magento\Framework\Locale\ResolverInterface
45- */
46- private $ locale ;
47-
48- /**
49- * @var \Magento\Framework\View\Element\BlockInterface
50- */
51- private $ fieldRenderer ;
31+ private ModuleListInterface $ moduleList ;
32+ private LayoutFactory $ layoutFactory ;
33+ private Reader $ moduleReader ;
34+ private Json $ serializer ;
35+ private File $ filesystem ;
36+ private BlockInterface $ fieldRenderer ;
37+ private ScopeConfigInterface $ scopeConfig ;
5238
53- /**
54- * @var \Magento\Framework\App\Config\ScopeConfigInterface
55- */
56- private $ scopeConfig ;
57-
58- /**
59- * @param \Magento\Framework\Module\ModuleListInterface $moduleList
60- * @param \Magento\Framework\Module\Dir\Reader $moduleReader
61- * @param \Magento\Framework\Filesystem\Driver\File $filesystem
62- * @param \Magento\Framework\Locale\ResolverInterface $locale
63- * @param \Magento\Framework\Json\DecoderInterface $jsonDecoder
64- * @param \Magento\Framework\View\LayoutFactory $layoutFactory
65- * @param \Magento\Backend\Block\Context $context
66- * @param \Magento\Backend\Model\Auth\Session $authSession
67- * @param \Magento\Framework\View\Helper\Js $jsHelper
68- * @param array $data
69- *
70- * @SuppressWarnings(PHPMD.ExcessiveParameterList)
71- */
7239 public function __construct (
73- \Magento \Framework \Module \ModuleListInterface $ moduleList ,
74- \Magento \Framework \Module \Dir \Reader $ moduleReader ,
75- \Magento \Framework \Filesystem \Driver \File $ filesystem ,
76- \Magento \Framework \Locale \ResolverInterface $ locale ,
77- \Magento \Framework \Json \DecoderInterface $ jsonDecoder ,
78- \Magento \Framework \View \LayoutFactory $ layoutFactory ,
79- \Magento \Backend \Block \Context $ context ,
80- \Magento \Backend \Model \Auth \Session $ authSession ,
81- \Magento \Framework \View \Helper \Js $ jsHelper ,
40+ ModuleListInterface $ moduleList ,
41+ Reader $ moduleReader ,
42+ File $ filesystem ,
43+ Json $ jsonDecoder ,
44+ LayoutFactory $ layoutFactory ,
45+ Context $ context ,
46+ Session $ authSession ,
47+ Js $ jsHelper ,
8248 array $ data = [],
8349 ) {
8450 parent ::__construct ($ context , $ authSession , $ jsHelper , $ data );
8551
8652 $ this ->moduleList = $ moduleList ;
8753 $ this ->layoutFactory = $ layoutFactory ;
8854 $ this ->moduleReader = $ moduleReader ;
89- $ this ->jsonDecoder = $ jsonDecoder ;
55+ $ this ->serializer = $ jsonDecoder ;
9056 $ this ->filesystem = $ filesystem ;
91- $ this ->locale = $ locale ;
9257 $ this ->scopeConfig = $ context ->getScopeConfig ();
9358 }
9459
9560 /**
9661 * Render fieldset html
97- *
98- * @param AbstractElement $element
99- * @return string
10062 */
101- public function render (AbstractElement $ element )
63+ public function render (AbstractElement $ element ): string
10264 {
10365 $ html = $ this ->_getHeaderHtml ($ element );
10466
105- $ site = 'https://www.mygento.net ' ;
106- $ email = 'connect@mygento.net ' ;
107-
108- if ($ this ->locale ->getLocale () === 'ru_RU ' ) {
109- $ site = 'https://www.mygento.ru ' ;
110- $ email = 'connect@mygento.ru ' ;
111- }
67+ $ site = 'https://www.mygento.com ' ;
68+ $ email = 'hello@mygento.сom ' ;
11269
113- $ ticketUrl = 'mailto:support@mygento.ru ' ;
114- $ url = __ (
115- 'Purchased extensions support is available through '
116- . '<a href="%1" target="_blank">ticket tracking system</a> ' ,
117- $ ticketUrl ,
118- );
119- $ bugs = __ ('Please report all bugs and feature requests. ' );
120- $ emailtext = __ (
121- 'If for some reasons you can not submit ticket '
122- . 'to our system, you can write us an email %1. ' ,
123- $ email ,
124- );
70+ $ bugs = __ ('Please report all bugs and feature requests to %1. ' , $ email );
12571 $ hiretext = __ (
12672 'You can hire us for any Magento extension customization and development. '
127- . '<br/>Write us to %1 ' ,
73+ . '<br/>Write us to %1 ' ,
12874 $ email ,
12975 );
130- $ tender = __ ('Tender offer can be checked '
131- . '<a href="https://www.mygento.ru/oferta" target="_blank">here</a> ' );
76+ $ tender = '<a href="https://mygento.com/impressum" target="_blank"> ' . __ ('Legal information ' ) . '</a> ' ;
13277
13378 $ html .= '<table class="mygento-info" cellspacing="0" cellpading="0"> '
13479 . '<tr class="mygento-info-line"> ' ;
13580 $ html .= '<tr><td> ' . __ ('Support ' ) . ':</td> ' .
136- '<td> ' . $ url . '.<br/><br/> ' . $ bugs .
137- '<br/><br/> ' . $ emailtext . '</td></tr> ' ;
81+ '<td> ' . $ bugs . '</td></tr> ' ;
13882 $ html .= '<tr><td> ' . __ ('License ' ) . ':</td><td> ' . $ tender . '</td></tr> ' ;
13983 $ html .= '<tr class="mygento-info-line "><td> '
140- . '<img src="//www.mygento.ru /media/wysiwyg/logo_base.png" width="100" height="100"/> '
84+ . '<img src="https: //www.mygento.com /media/wysiwyg/logo_base.png" width="100" height="100"/> '
14185 . '</td><td> ' . $ hiretext . '<br/><br/> ' . __ (
14286 'You can check all providable services on '
143- . '<a href="%1" target="_blank">our website</a>. ' ,
87+ . '<a href="%1" target="_blank">our website</a>. ' ,
14488 $ site . '/services ' ,
14589 ) . '</td></tr><tr class="mygento-info-line"></tr> ' ;
14690 $ html .= '</table> ' ;
14791
14892 $ modules = $ this ->moduleList ->getNames ();
14993
150- $ dispatchResult = new \Magento \Framework \DataObject ($ modules );
151- $ modules = $ dispatchResult ->toArray ();
152-
15394 $ html .= '<h2> ' . __ ('Installed Extensions ' ) . '</h2> ' ;
15495 $ html .= '<ul class="mygento-mod-list"> ' ;
15596 sort ($ modules );
@@ -176,7 +117,7 @@ private function getFieldRenderer()
176117 $ layout = $ this ->layoutFactory ->create ();
177118
178119 $ this ->fieldRenderer = $ layout ->createBlock (
179- \ Magento \ Config \ Block \ System \ Config \ Form \ Field::class,
120+ Field::class,
180121 );
181122 }
182123
@@ -186,21 +127,21 @@ private function getFieldRenderer()
186127 /**
187128 * Read info about extension from composer json file
188129 * @param string $moduleCode
189- * @throws \Magento\Framework\Exception\ FileSystemException
130+ * @throws FileSystemException
190131 * @return mixed
191132 */
192- private function getModuleInfo ($ moduleCode )
133+ private function getModuleInfo (string $ moduleCode )
193134 {
194135 $ dir = $ this ->moduleReader ->getModuleDir ('' , $ moduleCode );
195136 $ file = $ dir . DIRECTORY_SEPARATOR . 'composer.json ' ;
196137
197138 try {
198139 $ string = $ this ->filesystem ->fileGetContents ($ file );
199- } catch (\ Magento \ Framework \ Exception \ FileSystemException $ e ) {
140+ } catch (FileSystemException $ e ) {
200141 return null ;
201142 }
202143
203- return $ this ->jsonDecoder -> decode ($ string );
144+ return $ this ->serializer -> unserialize ($ string );
204145 }
205146
206147 /**
@@ -209,7 +150,7 @@ private function getModuleInfo($moduleCode)
209150 * @param string $moduleCode
210151 * @return string
211152 */
212- private function getFieldHtml (AbstractElement $ fieldset , $ moduleCode )
153+ private function getFieldHtml (AbstractElement $ fieldset , string $ moduleCode ): string
213154 {
214155 $ module = $ this ->getModuleInfo ($ moduleCode );
215156 if (
0 commit comments