Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ auth.json
/generate
/generated
.phpunit.result.cache
Test/tmp
20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

149 changes: 45 additions & 104 deletions Block/Extensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,148 +8,89 @@

namespace Mygento\Base\Block;

use Magento\Backend\Block\Context;
use Magento\Backend\Model\Auth\Session;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Config\Block\System\Config\Form\Fieldset;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\Exception\FileSystemException;
use Magento\Framework\Filesystem\Driver\File;
use Magento\Framework\Module\Dir\Reader;
use Magento\Framework\Module\ModuleListInterface;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\Framework\View\Element\BlockInterface;
use Magento\Framework\View\Helper\Js;
use Magento\Framework\View\LayoutFactory;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Extensions extends \Magento\Config\Block\System\Config\Form\Fieldset
class Extensions extends Fieldset
{
/**
* @var \Magento\Framework\Module\ModuleListInterface
*/
private $moduleList;

/**
* @var \Magento\Framework\View\LayoutFactory
*/
private $layoutFactory;

/**
* @var \Magento\Framework\Module\Dir\Reader
*/
private $moduleReader;

/**
* @var \Magento\Framework\Json\DecoderInterface
*/
private $jsonDecoder;

/**
* @var \Magento\Framework\Filesystem\Driver\File
*/
private $filesystem;

/**
* @var \Magento\Framework\Locale\ResolverInterface
*/
private $locale;

/**
* @var \Magento\Framework\View\Element\BlockInterface
*/
private $fieldRenderer;
private ModuleListInterface $moduleList;
private LayoutFactory $layoutFactory;
private Reader $moduleReader;
private Json $serializer;
private File $filesystem;
private BlockInterface $fieldRenderer;
private ScopeConfigInterface $scopeConfig;

/**
* @var \Magento\Framework\App\Config\ScopeConfigInterface
*/
private $scopeConfig;

/**
* @param \Magento\Framework\Module\ModuleListInterface $moduleList
* @param \Magento\Framework\Module\Dir\Reader $moduleReader
* @param \Magento\Framework\Filesystem\Driver\File $filesystem
* @param \Magento\Framework\Locale\ResolverInterface $locale
* @param \Magento\Framework\Json\DecoderInterface $jsonDecoder
* @param \Magento\Framework\View\LayoutFactory $layoutFactory
* @param \Magento\Backend\Block\Context $context
* @param \Magento\Backend\Model\Auth\Session $authSession
* @param \Magento\Framework\View\Helper\Js $jsHelper
* @param array $data
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
\Magento\Framework\Module\ModuleListInterface $moduleList,
\Magento\Framework\Module\Dir\Reader $moduleReader,
\Magento\Framework\Filesystem\Driver\File $filesystem,
\Magento\Framework\Locale\ResolverInterface $locale,
\Magento\Framework\Json\DecoderInterface $jsonDecoder,
\Magento\Framework\View\LayoutFactory $layoutFactory,
\Magento\Backend\Block\Context $context,
\Magento\Backend\Model\Auth\Session $authSession,
\Magento\Framework\View\Helper\Js $jsHelper,
ModuleListInterface $moduleList,
Reader $moduleReader,
File $filesystem,
Json $jsonDecoder,
LayoutFactory $layoutFactory,
Context $context,
Session $authSession,
Js $jsHelper,
array $data = [],
) {
parent::__construct($context, $authSession, $jsHelper, $data);

$this->moduleList = $moduleList;
$this->layoutFactory = $layoutFactory;
$this->moduleReader = $moduleReader;
$this->jsonDecoder = $jsonDecoder;
$this->serializer = $jsonDecoder;
$this->filesystem = $filesystem;
$this->locale = $locale;
$this->scopeConfig = $context->getScopeConfig();
}

/**
* Render fieldset html
*
* @param AbstractElement $element
* @return string
*/
public function render(AbstractElement $element)
public function render(AbstractElement $element): string
{
$html = $this->_getHeaderHtml($element);

$site = 'https://www.mygento.net';
$email = '[email protected]';

if ($this->locale->getLocale() === 'ru_RU') {
$site = 'https://www.mygento.ru';
$email = '[email protected]';
}
$site = 'https://www.mygento.com';
$email = 'hello@mygento.сom';

$ticketUrl = 'mailto:[email protected]';
$url = __(
'Purchased extensions support is available through '
. '<a href="%1" target="_blank">ticket tracking system</a>',
$ticketUrl,
);
$bugs = __('Please report all bugs and feature requests.');
$emailtext = __(
'If for some reasons you can not submit ticket '
. 'to our system, you can write us an email %1.',
$email,
);
$bugs = __('Please report all bugs and feature requests to %1.', $email);
$hiretext = __(
'You can hire us for any Magento extension customization and development.'
. '<br/>Write us to %1',
. '<br/>Write us to %1',
$email,
);
$tender = __('Tender offer can be checked '
. '<a href="https://www.mygento.ru/oferta" target="_blank">here</a>');
$tender = '<a href="https://mygento.com/impressum" target="_blank">' . __('Legal information') . '</a>';

$html .= '<table class="mygento-info" cellspacing="0" cellpading="0">'
. '<tr class="mygento-info-line">';
$html .= '<tr><td>' . __('Support') . ':</td>' .
'<td>' . $url . '.<br/><br/>' . $bugs .
'<br/><br/>' . $emailtext . '</td></tr>';
'<td>' . $bugs . '</td></tr>';
$html .= '<tr><td>' . __('License') . ':</td><td>' . $tender . '</td></tr>';
$html .= '<tr class="mygento-info-line "><td>'
. '<img src="//www.mygento.ru/media/wysiwyg/logo_base.png" width="100" height="100"/>'
. '<img src="https://www.mygento.com/media/wysiwyg/logo_base.png" width="100" height="100"/>'
. '</td><td>' . $hiretext . '<br/><br/>' . __(
'You can check all providable services on '
. '<a href="%1" target="_blank">our website</a>.',
. '<a href="%1" target="_blank">our website</a>.',
$site . '/services',
) . '</td></tr><tr class="mygento-info-line"></tr>';
$html .= '</table>';

$modules = $this->moduleList->getNames();

$dispatchResult = new \Magento\Framework\DataObject($modules);
$modules = $dispatchResult->toArray();

$html .= '<h2>' . __('Installed Extensions') . '</h2>';
$html .= '<ul class="mygento-mod-list">';
sort($modules);
Expand All @@ -176,7 +117,7 @@ private function getFieldRenderer()
$layout = $this->layoutFactory->create();

$this->fieldRenderer = $layout->createBlock(
\Magento\Config\Block\System\Config\Form\Field::class,
Field::class,
);
}

Expand All @@ -186,21 +127,21 @@ private function getFieldRenderer()
/**
* Read info about extension from composer json file
* @param string $moduleCode
* @throws \Magento\Framework\Exception\FileSystemException
* @throws FileSystemException
* @return mixed
*/
private function getModuleInfo($moduleCode)
private function getModuleInfo(string $moduleCode)
{
$dir = $this->moduleReader->getModuleDir('', $moduleCode);
$file = $dir . DIRECTORY_SEPARATOR . 'composer.json';

try {
$string = $this->filesystem->fileGetContents($file);
} catch (\Magento\Framework\Exception\FileSystemException $e) {
} catch (FileSystemException $e) {
return null;
}

return $this->jsonDecoder->decode($string);
return $this->serializer->unserialize($string);
}

/**
Expand All @@ -209,7 +150,7 @@ private function getModuleInfo($moduleCode)
* @param string $moduleCode
* @return string
*/
private function getFieldHtml(AbstractElement $fieldset, $moduleCode)
private function getFieldHtml(AbstractElement $fieldset, string $moduleCode): string
{
$module = $this->getModuleInfo($moduleCode);
if (
Expand Down
36 changes: 19 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
# Mygento Base module

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

## Description

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

* Helper для работы с налогами и чеками 54-ФЗ
* Helper для ресайза любых картинок
* Helper для работы с валютой
* Helper для определения статуса задачи крон
* Блок Ajax кнопки для system.xml
* Блок Cron кнопки для system.xml
* Общие блоки и модели для CRUD
* Модель для загрузки файлов в CRUD
* Компонент превью картинки для GRID
* Расширенный логгер с возможностью записи в БД
* Модель для загрузки файлов в system.xml
## Core Extension

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

## Автотесты
* Работа с налогами и чеками 54-ФЗ
## Autotests

- Handle taxes and cheques for 54-FZ
28 changes: 28 additions & 0 deletions README.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Mygento Base module

[![Build Status](https://github.com/mygento/module-base/actions/workflows/grumphp.yml/badge.svg)](https://github.com/mygento/module-base/actions/workflows/grumphp.yml)
[![Latest Stable Version](https://poser.pugx.org/mygento/module-base/v/stable)](https://packagist.org/packages/mygento/module-base)
[![License](https://poser.pugx.org/mygento/module-base/license)](https://packagist.org/packages/mygento/module-base)
[![Total Downloads](https://poser.pugx.org/mygento/module-base/downloads)](https://packagist.org/packages/mygento/module-base)

## Функционал

- Helper для работы с налогами и чеками 54-ФЗ
- Helper для ресайза любых картинок
- Helper для работы с валютой
- Helper для определения статуса задачи крон
- Блок Ajax кнопки для system.xml
- Блок Cron кнопки для system.xml
- Общие блоки и модели для CRUD
- Модель для загрузки файлов в CRUD
- Компонент превью картинки для GRID
- Расширенный логгер с возможностью записи в БД
- Модель для загрузки файлов в system.xml

## Расширение ядра

- Плагин: Дополнительные виды платежных транзакции - чек покупки и чек возврата

## Автотесты

- Работа с налогами и чеками 54-ФЗ
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "mygento/module-base",
"type": "magento2-module",
"version": "2.4.3",
"license": "OSL-3.0",
"homepage": "https://github.com/mygento/module-base",
"description": "Mygento Base",
Expand Down
2 changes: 1 addition & 1 deletion etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</group>
<group id="logger" translate="label" type="text" sortOrder="110" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Logging</label>
<field id="target" translate="label comment" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0">
<field id="target" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Log Destination</label>
<source_model>Mygento\Base\Model\Source\LogTarget</source_model>
</field>
Expand Down
7 changes: 6 additions & 1 deletion i18n/ru_RU.csv
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@
"Last Update","Последнее обновление"
"Scheduled or Running","Запланировано или в работе"
"Job Code is required","Требуется код задачи"
"Job Status","Статус задачи"
"Job Status","Статус задачи"
"Please report all bugs and feature requests to %1.","Если у вас есть ошибки или предложения по работе можете смело писать нам на %1."
"Legal information","Правовая информация"
"General Setting","Основные настройки"
"Logging","Логирование"
"Log Destination","Логировать в"
12 changes: 2 additions & 10 deletions view/adminhtml/layout/adminhtml_system_config_edit.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
<?xml version="1.0"?>
<!--
/**
* @author Mygento Team
* @copyright Copyright 2014-2018 Mygento (https://www.mygento.ru)
* @package Mygento_Base
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="Mygento_Base::css/main.css"/>
</head>
</page>
</page>
Loading