From 44d6f7596dcd96d2f656e4cec7d3cb67441297b5 Mon Sep 17 00:00:00 2001 From: Vincent Garcia Date: Fri, 5 Jul 2024 16:43:15 +0200 Subject: [PATCH] :sparkles: Be sure URL of MBO is the correct one on the dependencies array --- src/DependencyBuilder.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/DependencyBuilder.php b/src/DependencyBuilder.php index 554ff31..bbc9dad 100644 --- a/src/DependencyBuilder.php +++ b/src/DependencyBuilder.php @@ -8,10 +8,10 @@ class DependencyBuilder { - const DEPENDENCY_FILENAME = 'module_dependencies.json'; - const GET_PARAMETER = 'mbo_action_needed'; - const DEFAULT_LOCALE = 'en-GB'; - const DEFAULT_HELP_URLS = [ + public const DEPENDENCY_FILENAME = 'module_dependencies.json'; + public const GET_PARAMETER = 'mbo_action_needed'; + public const DEFAULT_LOCALE = 'en-GB'; + public const DEFAULT_HELP_URLS = [ 'en_GB' => 'https://addons.prestashop.com/en/contact-us', 'en_US' => 'https://addons.prestashop.com/en/contact-us', 'de_DE' => 'https://addons.prestashop.com/de/contact-us', @@ -204,10 +204,16 @@ protected function buildRoutesForModule($moduleName) { $urls = []; foreach (['install', 'enable', 'upgrade'] as $action) { - $route = $this->router->generate('admin_module_manage_action', [ - 'action' => $action, - 'module_name' => $moduleName, - ]); + if ($action === 'install' && $moduleName === 'ps_mbo' && !empty($_SERVER['REQUEST_URI'])) { + $query = http_build_query(array_merge($_GET, [self::GET_PARAMETER => '1'])); + $baseUri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); + $route = $baseUri . '?' . $query; + } else { + $route = $this->router->generate('admin_module_manage_action', [ + 'action' => $action, + 'module_name' => $moduleName, + ]); + } if (is_string($route)) { $urls[$action] = $route;