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
22 changes: 10 additions & 12 deletions config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 0 additions & 4 deletions src/Admin/ModuleDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
55 changes: 3 additions & 52 deletions src/ConfigForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
namespace Hhennes\ModulesManager;

use Configuration;
use Symfony\Component\Filesystem\Filesystem;

class ConfigForm
{
Expand Down Expand Up @@ -51,6 +50,8 @@ public function __construct(\HhModulesManager $module, \Context $context)
* Manage configuration upgrade
*
* @return string|void
*
* @throws \PrestaShopException
*/
public function postProcess()
{
Expand All @@ -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'));
Expand Down Expand Up @@ -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
*
Expand Down
34 changes: 0 additions & 34 deletions views/PrestaShop/Admin/Module/Includes/index.php

This file was deleted.

This file was deleted.

27 changes: 0 additions & 27 deletions views/templates/admin/e/helpers/list/list_footer.tpl

This file was deleted.

Loading