diff --git a/config/services.yml b/config/services.yml index 0d37cf9..4898970 100644 --- a/config/services.yml +++ b/config/services.yml @@ -48,18 +48,16 @@ services: #Module upgrade filter in back office - #Ne fonctionne qu'à partir de prestashop 8+ ... - #Voir comment faire cohabiter les différentes versions - #Car signatures différentes -# hhennes.modulesmanager.adapter.admin.data_provider.module: -# class: Hhennes\ModulesManager\Admin\ModuleDataProvider -# decorates: prestashop.core.admin.data_provider.module_interface -# arguments: -# - "@prestashop.categories_provider" -# - "@prestashop.adapter.data_provider.module" -# - "@=service('prestashop.adapter.legacy.context').getContext().employee" -# calls: -# - [ setRouter, [ '@router' ] ] + hhennes.modulesmanager.adapter.admin.data_provider.module: + class: Hhennes\ModulesManager\Admin\ModuleDataProvider + decorates: PrestaShop\PrestaShop\Adapter\Module\AdminModuleDataProvider + arguments: + - "@prestashop.adapter.data_provider.module" + - '@translator' + - "@=service('prestashop.adapter.legacy.context').getContext().employee" + - '@PrestaShop\PrestaShop\Core\Context\ApiClientContext' + calls: + - [ setRouter, [ '@router' ] ] #Decorator for the translation service to dispatch the event hhennes.modulesmanager.service.translation: diff --git a/src/Admin/ModuleDataProvider.php b/src/Admin/ModuleDataProvider.php index bda96d6..93d2d86 100644 --- a/src/Admin/ModuleDataProvider.php +++ b/src/Admin/ModuleDataProvider.php @@ -23,10 +23,6 @@ use PrestaShop\PrestaShop\Adapter\Module\Module; use PrestaShop\PrestaShop\Core\Module\ModuleCollection; -/** - * This class is not used yet as it works only on prestashop 8+ - * Work In Progress to check how we can use it on older versions too - */ class ModuleDataProvider extends AdminModuleDataProvider { /** @var string Configuration name which defines if modules upgrades are enable in back office */ diff --git a/src/ConfigForm.php b/src/ConfigForm.php index f2704ac..42f2576 100644 --- a/src/ConfigForm.php +++ b/src/ConfigForm.php @@ -19,7 +19,6 @@ namespace Hhennes\ModulesManager; use Configuration; -use Symfony\Component\Filesystem\Filesystem; class ConfigForm { @@ -51,6 +50,8 @@ public function __construct(\HhModulesManager $module, \Context $context) * Manage configuration upgrade * * @return string|void + * + * @throws \PrestaShopException */ public function postProcess() { @@ -71,8 +72,7 @@ public function postProcess() && \Configuration::updateValue( $this->configPrefix . 'ENABLE_TRANSLATION_TRACKING', \Tools::getValue($this->configPrefix . 'ENABLE_TRANSLATION_TRACKING') - ) - && $this->toggleModuleUpdate((bool) $enableUpdate)) { + )) { return $this->module->displayConfirmation($this->l('Settings Updated')); } else { return $this->module->displayError($this->l('Unable to update settings')); @@ -181,55 +181,6 @@ protected function getFieldValues(): array ]; } - /** - * Toggle Module Update by changing template name - * - * @param bool $enable - * - * @return bool - */ - protected function toggleModuleUpdate($enable): bool - { - $fileSystem = new Filesystem(); - $updagradeTemplatePath = _PS_MODULE_DIR_ . $this->module->name . '/views/PrestaShop/Admin/Module/Includes/'; - - if (true === $enable) { - try { - if ($fileSystem->exists($updagradeTemplatePath . 'action_button.html.twig')) { - $fileSystem->remove($updagradeTemplatePath . 'action_button.html.twig'); - } - if (!$fileSystem->exists($updagradeTemplatePath . 'action_button.html.twig.disabled')) { - $fileSystem->copy( - $updagradeTemplatePath . 'action_button.html.twig.file', - $updagradeTemplatePath . 'action_button.html.twig.disabled' - ); - } - - return true; - } catch (\Exception $e) { - return false; - } - } - - if (false === $enable) { - try { - if ($fileSystem->exists($updagradeTemplatePath . 'action_button.html.twig.disabled')) { - $fileSystem->remove($updagradeTemplatePath . 'action_button.html.twig.disabled'); - } - if (!$fileSystem->exists($updagradeTemplatePath . 'action_button.html.twig')) { - $fileSystem->copy( - $updagradeTemplatePath . 'action_button.html.twig.file', - $updagradeTemplatePath . 'action_button.html.twig' - ); - } - - return true; - } catch (\Exception $e) { - return false; - } - } - } - /** * Alias for translate function * diff --git a/views/PrestaShop/Admin/Module/Includes/index.php b/views/PrestaShop/Admin/Module/Includes/index.php deleted file mode 100644 index 897dd5e..0000000 --- a/views/PrestaShop/Admin/Module/Includes/index.php +++ /dev/null @@ -1,34 +0,0 @@ - - -* @copyright 2007-2016 PrestaShop SA -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); -header('Location: ../'); -exit; diff --git a/views/templates/admin/change/helpers/list/list_action_update.tpl b/views/templates/admin/change/helpers/list/list_action_update.tpl deleted file mode 100644 index d357970..0000000 --- a/views/templates/admin/change/helpers/list/list_action_update.tpl +++ /dev/null @@ -1,3 +0,0 @@ - - {$action|escape:'html':'UTF-8'} - \ No newline at end of file diff --git a/views/templates/admin/e/helpers/list/list_footer.tpl b/views/templates/admin/e/helpers/list/list_footer.tpl deleted file mode 100644 index b1ce06d..0000000 --- a/views/templates/admin/e/helpers/list/list_footer.tpl +++ /dev/null @@ -1,27 +0,0 @@ -{** - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file docs/licenses/LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to contact@h-hennes.fr so we can send you a copy immediately. - * - * @author Hervé HENNES - * @copyright since 2023 Hervé HENNES - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License ("AFL") v. 3.0 - *} -{extends file="helpers/list/list_footer.tpl"} -{block name="after"} - {if isset($display_warning)} -
-

{l s='Warning' mod=''}

-

- {l s='The event recorder is not enabled on this environnement' mod='hhmodulesmanager'}
- {l s='You won\'t be abble to generate upgrade file, but it is the attended behavior on non developpement environnements' mod='hhmodulesmanager'} -

-
- {/if} -{/block}