refactor to composer api

Non working state
This commit is contained in:
Walz
2025-04-08 16:08:09 +02:00
parent 20eacdf96c
commit 1b27d03c4d
12 changed files with 405 additions and 38 deletions

View File

@ -82,44 +82,13 @@ class GdprCookieConsent extends Module
*/
public function getContent()
{
$output = '';
// If form submitted
if (Tools::isSubmit('submitGdprCookieModule')) {
// Get configuration values from form
$enabled = (int)Tools::getValue('GDPR_COOKIE_ENABLED');
$message = Tools::getValue('GDPR_COOKIE_MESSAGE');
$accept = Tools::getValue('GDPR_COOKIE_ACCEPT');
$decline = Tools::getValue('GDPR_COOKIE_DECLINE');
$settings = Tools::getValue('GDPR_COOKIE_SETTINGS');
$moreInfo = Tools::getValue('GDPR_COOKIE_MORE_INFO');
$moreInfoUrl = Tools::getValue('GDPR_COOKIE_MORE_INFO_URL');
$dataController = Tools::getValue('GDPR_COOKIE_DATA_CONTROLLER');
$retentionPeriod = Tools::getValue('GDPR_COOKIE_RETENTION_PERIOD');
$thirdParties = Tools::getValue('GDPR_COOKIE_THIRD_PARTIES');
$manageText = Tools::getValue('GDPR_COOKIE_MANAGE_TEXT');
$onlyRequired = Tools::getValue('GDPR_COOKIE_ONLY_REQUIRED');
// Update configuration values
Configuration::updateValue('GDPR_COOKIE_ENABLED', $enabled);
Configuration::updateValue('GDPR_COOKIE_MESSAGE', $message);
Configuration::updateValue('GDPR_COOKIE_ACCEPT', $accept);
Configuration::updateValue('GDPR_COOKIE_DECLINE', $decline);
Configuration::updateValue('GDPR_COOKIE_SETTINGS', $settings);
Configuration::updateValue('GDPR_COOKIE_MORE_INFO', $moreInfo);
Configuration::updateValue('GDPR_COOKIE_MORE_INFO_URL', $moreInfoUrl);
Configuration::updateValue('GDPR_COOKIE_DATA_CONTROLLER', $dataController);
Configuration::updateValue('GDPR_COOKIE_RETENTION_PERIOD', $retentionPeriod);
Configuration::updateValue('GDPR_COOKIE_THIRD_PARTIES', $thirdParties);
Configuration::updateValue('GDPR_COOKIE_MANAGE_TEXT', $manageText);
Configuration::updateValue('GDPR_COOKIE_ONLY_REQUIRED', $onlyRequired);
// Display confirmation
$output .= $this->displayConfirmation($this->l('Settings updated'));
try {
// Redirect to the Symfony controller
Tools::redirectAdmin($this->get('router')->generate('gdpr_cookie_consent_configuration'));
} catch (\Exception $e) {
// Fallback in case of error
return $this->displayError($this->l('An error occurred while trying to redirect to the configuration page.'));
}
// Display the configuration form
return $output . $this->displayForm();
}
/**
@ -347,4 +316,19 @@ class GdprCookieConsent extends Module
return $this->display(__FILE__, 'views/templates/hook/footer.tpl');
}
/**
* Load the dependency injection container
*
* @param array $params
*/
public function hookActionFrontControllerSetMedia(array $params)
{
// Do not load the container if it's already loaded
if ($this->container !== null) {
return;
}
$this->container = \PrestaShop\PrestaShop\Adapter\SymfonyContainer::getInstance();
}
}