Skip to content

Commit c566551

Browse files
authored
Modernize (#54)
1 parent 9846df8 commit c566551

9 files changed

Lines changed: 102 additions & 154 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ auth.json
1010
/generate
1111
/generated
1212
.phpunit.result.cache
13+
Test/tmp

.travis.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

Block/Extensions.php

Lines changed: 45 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -8,148 +8,89 @@
88

99
namespace 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;
1116
use 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 (

README.md

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
# Mygento Base module
22

3-
[![Build Status](https://travis-ci.com/mygento/module-base.svg?branch=v2.4)](https://travis-ci.com/mygento/module-base)
3+
[![Build Status](https://github.com/mygento/module-base/actions/workflows/grumphp.yml/badge.svg)](https://github.com/mygento/module-base/actions/workflows/grumphp.yml)
44
[![Latest Stable Version](https://poser.pugx.org/mygento/module-base/v/stable)](https://packagist.org/packages/mygento/module-base)
5+
[![License](https://poser.pugx.org/mygento/module-base/license)](https://packagist.org/packages/mygento/module-base)
56
[![Total Downloads](https://poser.pugx.org/mygento/module-base/downloads)](https://packagist.org/packages/mygento/module-base)
67

8+
## Description
79

8-
## Функционал
10+
- Helper for taxes and cheques for 54-FZ
11+
- Helper for any images resizing
12+
- Helper working with currencies
13+
- Helper for understanding cron task status
14+
- Ready Ajax button Block for system.xml
15+
- Ready Cron button Block for system.xml
16+
- Common blocks & models for CRUD
17+
- Model for loading files into CRUD
18+
- Image preview component for GRID
19+
- Enhanced logger with ability to write to DB /
20+
- Model for loading files in system.xml
921

10-
* Helper для работы с налогами и чеками 54-ФЗ
11-
* Helper для ресайза любых картинок
12-
* Helper для работы с валютой
13-
* Helper для определения статуса задачи крон
14-
* Блок Ajax кнопки для system.xml
15-
* Блок Cron кнопки для system.xml
16-
* Общие блоки и модели для CRUD
17-
* Модель для загрузки файлов в CRUD
18-
* Компонент превью картинки для GRID
19-
* Расширенный логгер с возможностью записи в БД
20-
* Модель для загрузки файлов в system.xml
22+
## Core Extension
2123

22-
## Расширение ядра
23-
* Плагин: Дополнительные виды платежных транзакции - чек покупки и чек возврата
24+
- Plugin: Extended type of payment transactions - buy and refund receipt
2425

25-
## Автотесты
26-
* Работа с налогами и чеками 54-ФЗ
26+
## Autotests
27+
28+
- Handle taxes and cheques for 54-FZ

README.ru

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Mygento Base module
2+
3+
[![Build Status](https://github.com/mygento/module-base/actions/workflows/grumphp.yml/badge.svg)](https://github.com/mygento/module-base/actions/workflows/grumphp.yml)
4+
[![Latest Stable Version](https://poser.pugx.org/mygento/module-base/v/stable)](https://packagist.org/packages/mygento/module-base)
5+
[![License](https://poser.pugx.org/mygento/module-base/license)](https://packagist.org/packages/mygento/module-base)
6+
[![Total Downloads](https://poser.pugx.org/mygento/module-base/downloads)](https://packagist.org/packages/mygento/module-base)
7+
8+
## Функционал
9+
10+
- Helper для работы с налогами и чеками 54-ФЗ
11+
- Helper для ресайза любых картинок
12+
- Helper для работы с валютой
13+
- Helper для определения статуса задачи крон
14+
- Блок Ajax кнопки для system.xml
15+
- Блок Cron кнопки для system.xml
16+
- Общие блоки и модели для CRUD
17+
- Модель для загрузки файлов в CRUD
18+
- Компонент превью картинки для GRID
19+
- Расширенный логгер с возможностью записи в БД
20+
- Модель для загрузки файлов в system.xml
21+
22+
## Расширение ядра
23+
24+
- Плагин: Дополнительные виды платежных транзакции - чек покупки и чек возврата
25+
26+
## Автотесты
27+
28+
- Работа с налогами и чеками 54-ФЗ

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "mygento/module-base",
33
"type": "magento2-module",
4-
"version": "2.4.3",
54
"license": "OSL-3.0",
65
"homepage": "https://github.com/mygento/module-base",
76
"description": "Mygento Base",

etc/adminhtml/system.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
</group>
3333
<group id="logger" translate="label" type="text" sortOrder="110" showInDefault="1" showInWebsite="1" showInStore="0">
3434
<label>Logging</label>
35-
<field id="target" translate="label comment" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0">
35+
<field id="target" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0">
3636
<label>Log Destination</label>
3737
<source_model>Mygento\Base\Model\Source\LogTarget</source_model>
3838
</field>

i18n/ru_RU.csv

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,9 @@
1818
"Last Update","Последнее обновление"
1919
"Scheduled or Running","Запланировано или в работе"
2020
"Job Code is required","Требуется код задачи"
21-
"Job Status","Статус задачи"
21+
"Job Status","Статус задачи"
22+
"Please report all bugs and feature requests to %1.","Если у вас есть ошибки или предложения по работе можете смело писать нам на %1."
23+
"Legal information","Правовая информация"
24+
"General Setting","Основные настройки"
25+
"Logging","Логирование"
26+
"Log Destination","Логировать в"
Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
<?xml version="1.0"?>
2-
<!--
3-
/**
4-
* @author Mygento Team
5-
* @copyright Copyright 2014-2018 Mygento (https://www.mygento.ru)
6-
* @package Mygento_Base
7-
*/
8-
-->
9-
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10-
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
2+
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
113
<head>
124
<css src="Mygento_Base::css/main.css"/>
135
</head>
14-
</page>
6+
</page>

0 commit comments

Comments
 (0)