diff --git a/bootstrap.php b/bootstrap.php index e10d0e889..978aa42f5 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -25,4 +25,6 @@ require_once $rootDir . '/vendor/autoload.php'; -(new \Symfony\Component\Dotenv\Dotenv(true))->loadEnv(__DIR__ . '/.env'); +(new \Symfony\Component\Dotenv\Dotenv()) + ->usePutenv() + ->loadEnv(__DIR__ . '/.env'); diff --git a/config/routes/addons.yml b/config/routes/addons.yml index 860f41749..20f42b8ba 100644 --- a/config/routes/addons.yml +++ b/config/routes/addons.yml @@ -2,4 +2,4 @@ admin_mbo_addons_module_upgrade: path: /modules/upgrade methods: [ POST ] defaults: - _controller: mbo.controller.addons:upgradeModuleAction + _controller: 'PrestaShop\Module\Mbo\Controller\Admin\AddonsController::upgradeModuleAction' diff --git a/config/routes/modules_catalog.yml b/config/routes/modules_catalog.yml index 040e707ec..57e618d42 100644 --- a/config/routes/modules_catalog.yml +++ b/config/routes/modules_catalog.yml @@ -2,7 +2,7 @@ admin_mbo_catalog_module: path: / methods: [GET] defaults: - _controller: mbo.controller.modules.catalog:indexAction + _controller: 'PrestaShop\Module\Mbo\Controller\Admin\ModuleCatalogController::indexAction' _legacy_controller: AdminPsMboModule _legacy_link: - AdminPsMboModuleParent @@ -12,7 +12,7 @@ admin_mbo_catalog_module_selection: path: /selection methods: [GET] defaults: - _controller: mbo.controller.modules.selection:indexAction + _controller: 'PrestaShop\Module\Mbo\Controller\Admin\ModuleSelectionController::indexAction' _legacy_controller: AdminPsMboSelection _legacy_link: AdminPsMboSelection @@ -20,4 +20,4 @@ admin_mbo_module_cdc_error: path: /cdc_error methods: [ GET ] defaults: - _controller: mbo.controller.modules.catalog:cdcErrorAction + _controller: 'PrestaShop\Module\Mbo\Controller\Admin\ModuleCatalogController::cdcErrorAction' diff --git a/config/routes/recommended_modules.yml b/config/routes/recommended_modules.yml index a601854f0..aa6d8158e 100644 --- a/config/routes/recommended_modules.yml +++ b/config/routes/recommended_modules.yml @@ -2,6 +2,6 @@ admin_mbo_recommended_modules: path: / methods: [GET] defaults: - _controller: mbo.controller.modules.recommended:indexAction + _controller: 'PrestaShop\Module\Mbo\Controller\Admin\ModuleRecommendedController::indexAction' _legacy_controller: AdminPsMboRecommended _legacy_link: AdminPsMboRecommended diff --git a/config/routes/theme_catalog.yml b/config/routes/theme_catalog.yml index 4df58824d..5e85f909a 100644 --- a/config/routes/theme_catalog.yml +++ b/config/routes/theme_catalog.yml @@ -2,6 +2,6 @@ admin_mbo_catalog_theme: path: / methods: [GET] defaults: - _controller: mbo.controller.themes.catalog:indexAction + _controller: 'PrestaShop\Module\Mbo\Controller\Admin\ThemeCatalogController::indexAction' _legacy_controller: AdminPsMboTheme _legacy_link: AdminPsMboTheme diff --git a/config/services.yml b/config/services.yml old mode 100644 new mode 100755 index 28c6e6a23..8215196b1 --- a/config/services.yml +++ b/config/services.yml @@ -6,43 +6,32 @@ services: _defaults: public: true - mbo.externalcontent.provider: - class: 'PrestaShop\Module\Mbo\Service\ExternalContentProvider\ExternalContentProvider' + Symfony\Contracts\Translation\TranslatorInterface: '@PrestaShopBundle\Translation\TranslatorInterface' - mbo.addons.links_provider: - class: 'PrestaShop\Module\Mbo\Addons\Provider\LinksProvider' - arguments: - - '@prestashop.core.foundation.version' - - '@prestashop.adapter.legacy.context' - - '@prestashop.adapter.legacy.configuration' - - '@request_stack' - - '@prestashop.categories_provider' - - '@translator' - - '@router' - - mbo.controller.modules.catalog: - class: 'PrestaShop\Module\Mbo\Controller\Admin\ModuleCatalogController' - - mbo.controller.modules.selection: - class: 'PrestaShop\Module\Mbo\Controller\Admin\ModuleSelectionController' - arguments: - - '@request_stack' + PrestaShop\Module\Mbo\Service\ExternalContentProvider\ExternalContentProviderInterface: '@PrestaShop\Module\Mbo\Service\ExternalContentProvider\ExternalContentProvider' - mbo.controller.modules.recommended: - class: 'PrestaShop\Module\Mbo\Controller\Admin\ModuleRecommendedController' - arguments: - - '@request_stack' - calls: - - [ setContainer, [ '@service_container' ] ] + PrestaShop\Module\Mbo\Service\ExternalContentProvider\ExternalContentProvider: + autowire: true - mbo.controller.themes.catalog: - class: 'PrestaShop\Module\Mbo\Controller\Admin\ThemeCatalogController' + PrestaShop\Module\Mbo\Addons\Provider\LinksProvider: + autowire: true arguments: - - '@request_stack' + $router: '@prestashop.router' + $categoriesProvider: '@prestashop.categories_provider' - mbo.controller.addons: - class: 'PrestaShop\Module\Mbo\Controller\Admin\AddonsController' - arguments: - - '@request_stack' - - '@prestashop.module.manager' - - '@prestashop.core.admin.module.repository' + PrestaShop\Module\Mbo\Controller\Admin\ModuleCatalogController: + autowire: true + autoconfigure: true + + PrestaShop\Module\Mbo\Controller\Admin\ModuleSelectionController: + autowire: true + + PrestaShop\Module\Mbo\Controller\Admin\ModuleRecommendedController: + autowire: true + autoconfigure: true + + PrestaShop\Module\Mbo\Controller\Admin\ThemeCatalogController: + autowire: true + + PrestaShop\Module\Mbo\Controller\Admin\AddonsController: + autowire: true diff --git a/config/services/accounts.yml b/config/services/accounts.yml index 4edabb49a..ed9d7b265 100644 --- a/config/services/accounts.yml +++ b/config/services/accounts.yml @@ -2,19 +2,16 @@ services: _defaults: public: true - mbo.ps_accounts.installer: - class: 'PrestaShop\PsAccountsInstaller\Installer\Installer' - public: true + PrestaShop\PsAccountsInstaller\Installer\Installer: + autowire: true arguments: - - "5.2.5" + $psAccountsVersion: "5.2.5" - mbo.ps_accounts.facade: - class: 'PrestaShop\PsAccountsInstaller\Installer\Facade\PsAccounts' - public: true - arguments: - - "@mbo.ps_accounts.installer" + PrestaShop\PsAccountsInstaller\Installer\Facade\PsAccounts: + autowire: true - mbo.accounts.data_provider: - class: PrestaShop\Module\Mbo\Accounts\Provider\AccountsDataProvider + PrestaShop\Module\Mbo\Accounts\Provider\AccountsDataProvider: + autowire: true + autoconfigure: true arguments: - - "5.2.5" + $psAccountsVersion: "5.2.5" diff --git a/config/services/addons.php b/config/services/addons.php index 7a7bb68b9..084e2f0ab 100644 --- a/config/services/addons.php +++ b/config/services/addons.php @@ -29,18 +29,9 @@ //Only load event subscriber when module is enabled to avoid logging events if disabled if (ps_mbo::checkModuleStatus()) { - $services->set('mbo.addons.event_subscriber', ModuleManagementEventSubscriber::class) - ->args([ - ref('logger'), - ref('mbo.modules.repository'), - ref('mbo.tab.collection.provider'), - ref('mbo.cdc.context_builder'), - ref('mbo.cdc.client.distribution_api'), - ref('mbo.security.admin_authentication.provider'), - ref('mbo.distribution.api_version_change_config_apply_handler'), - ref('mbo.symfony_cache_clearer'), - ]) - ->public() - ->tag('kernel.event_subscriber'); + $services->set(ModuleManagementEventSubscriber::class) + ->autowire() + ->public() + ->tag('kernel.event_subscriber'); } }; diff --git a/config/services/addons.yml b/config/services/addons.yml index 427187493..451912971 100644 --- a/config/services/addons.yml +++ b/config/services/addons.yml @@ -2,31 +2,24 @@ services: _defaults: public: true - mbo.addons.user: - class: PrestaShop\Module\Mbo\Addons\User\AddonsUser - arguments: - - '@session' - - '@mbo.accounts.data_provider' + PrestaShop\Module\Mbo\Addons\User\AddonsUser: + autowire: true + autoconfigure: true - mbo.addons.user.provider: - class: PrestaShop\Module\Mbo\Addons\User\AddonsUserProvider - arguments: - - "@mbo.addons.user" + PrestaShop\Module\Mbo\Addons\User\AddonsUserProvider: + autowire: true + autoconfigure: true - mbo.addons.data_provider: - class: PrestaShop\Module\Mbo\Addons\Provider\AddonsDataProvider - arguments: - - '@mbo.addons.client.api' - - '@=service("mbo.addons.user.provider").getUser()' - - '@=service("prestashop.adapter.legacy.configuration").get("ADDONS_API_MODULE_CHANNEL", "stable")' + PrestaShop\Module\Mbo\Addons\Provider\AddonsDataProvider: + autowire: true properties: cacheDir: "%kernel.cache_dir%" # Addons API Client - mbo.addons.client.api: - class: PrestaShop\Module\Mbo\Addons\ApiClient + PrestaShop\Module\Mbo\Addons\ApiClient: + autowire: true arguments: - - "@mbo.addons.client.http" + $httpClient: '@mbo.addons.client.http' calls: - method: setDefaultParams arguments: @@ -35,9 +28,5 @@ services: - "@=service('prestashop.adapter.legacy.configuration').get('_PS_BASE_URL_')" - "@=service('prestashop.core.foundation.version').getSemVersion()" - mbo.addons.toolbar: - class: PrestaShop\Module\Mbo\Addons\Toolbar - arguments: - - '@mbo.security.permission_checker' - - '@mbo.addons.data_provider' - - '@translator' + PrestaShop\Module\Mbo\Addons\Toolbar: + autowire: true diff --git a/config/services/api.yml b/config/services/api.yml index 5dac83d07..0e37dbd1b 100644 --- a/config/services/api.yml +++ b/config/services/api.yml @@ -16,23 +16,18 @@ services: - 'ps_mbo' PrestaShop\Module\Mbo\Api\Config\Env: - class: PrestaShop\Module\Mbo\Api\Config\Env + autowire: true - mbo.api.service.executors.module_transition: - class: PrestaShop\Module\Mbo\Api\Service\ModuleTransitionExecutor - arguments: - - '@mbo.modules.module_status_transition_handler' + PrestaShop\Module\Mbo\Api\Service\ModuleTransitionExecutor: + autowire: true - mbo.api.service.executors.config_apply: - class: PrestaShop\Module\Mbo\Api\Service\ConfigApplyExecutor - arguments: - - '@mbo.distribution.api_config_change_handler' - - '@ps_mbo' + PrestaShop\Module\Mbo\Api\Service\ConfigApplyExecutor: + autowire: true - mbo.api.service.factory: - class: PrestaShop\Module\Mbo\Api\Service\Factory + PrestaShop\Module\Mbo\Api\Service\Factory: + autowire: true arguments: - [ - '@mbo.api.service.executors.module_transition', - '@mbo.api.service.executors.config_apply' + '@PrestaShop\Module\Mbo\Api\Service\ModuleTransitionExecutor', + '@PrestaShop\Module\Mbo\Api\Service\ConfigApplyExecutor' ] diff --git a/config/services/api/distribution.yml b/config/services/api/distribution.yml index 5b2576e11..22bf31a31 100644 --- a/config/services/api/distribution.yml +++ b/config/services/api/distribution.yml @@ -2,37 +2,29 @@ services: _defaults: public: true - mbo.distribution.config_factory: - class: 'PrestaShop\Module\Mbo\Distribution\Config\Factory' + PrestaShop\Module\Mbo\Distribution\Config\Factory: + autowire: true - mbo.distribution.config_applier: - class: 'PrestaShop\Module\Mbo\Distribution\Config\Applier' - arguments: - - '@mbo.distribution.config_appliers_factory' + PrestaShop\Module\Mbo\Distribution\Config\Applier: + autowire: true - mbo.distribution.theme_catalog_menu_config_applier: - class: PrestaShop\Module\Mbo\Distribution\Config\Appliers\ThemeCatalogMenuConfigApplier + PrestaShop\Module\Mbo\Distribution\Config\Appliers\ThemeCatalogMenuConfigApplier: + autowire: true - mbo.distribution.module_selection_menu_config_applier: - class: PrestaShop\Module\Mbo\Distribution\Config\Appliers\ModuleSelectionMenuConfigApplier + PrestaShop\Module\Mbo\Distribution\Config\Appliers\ModuleSelectionMenuConfigApplier: + autowire: true - mbo.distribution.config_appliers_factory: - class: 'PrestaShop\Module\Mbo\Distribution\Config\Appliers\Factory' + PrestaShop\Module\Mbo\Distribution\Config\Appliers\Factory: + autowire: true arguments: - [ - '@mbo.distribution.theme_catalog_menu_config_applier', - '@mbo.distribution.module_selection_menu_config_applier' + '@PrestaShop\Module\Mbo\Distribution\Config\Appliers\ThemeCatalogMenuConfigApplier', + '@PrestaShop\Module\Mbo\Distribution\Config\Appliers\ModuleSelectionMenuConfigApplier' ] - mbo.distribution.api_config_change_handler: - class: 'PrestaShop\Module\Mbo\Distribution\Config\CommandHandler\ConfigChangeCommandHandler' - arguments: - - '@mbo.distribution.config_factory' - - '@mbo.distribution.config_applier' + PrestaShop\Module\Mbo\Distribution\Config\CommandHandler\ConfigChangeCommandHandler: + autowire: true - mbo.distribution.api_version_change_config_apply_handler: - class: 'PrestaShop\Module\Mbo\Distribution\Config\CommandHandler\VersionChangeApplyConfigCommandHandler' - arguments: - - '@mbo.distribution.config_factory' - - '@mbo.distribution.config_applier' + PrestaShop\Module\Mbo\Distribution\Config\CommandHandler\VersionChangeApplyConfigCommandHandler: + autowire: true diff --git a/config/services/api/modules.yml b/config/services/api/modules.yml index 337882adf..cadec3a48 100644 --- a/config/services/api/modules.yml +++ b/config/services/api/modules.yml @@ -2,35 +2,21 @@ services: _defaults: public: true - mbo.modules.source_retriever.url: - class: 'PrestaShop\Module\Mbo\Module\SourceRetriever\AddonsUrlSourceRetriever' + PrestaShop\Module\Mbo\Module\SourceRetriever\AddonsUrlSourceRetriever: + autowire: true arguments: - $addonsDataProvider: '@mbo.addons.data_provider' - $translator: '@translator' $modulePath: '%modules_dir%' properties: cacheDir: "%kernel.cache_dir%" - mbo.modules.transitions_manager: - class: 'PrestaShop\Module\Mbo\Module\Workflow\TransitionsManager' - arguments: - - '@prestashop.module.manager' - - '@mbo.hook_exception_holder' + PrestaShop\Module\Mbo\Module\Workflow\TransitionsManager: + autowire: true - mbo.modules.transition_builder: - class: PrestaShop\Module\Mbo\Module\Workflow\TransitionBuilder + PrestaShop\Module\Mbo\Module\Workflow\TransitionBuilder: + autowire: true - mbo.modules.transition_applier: - class: PrestaShop\Module\Mbo\Module\Workflow\TransitionApplier - arguments: - - '@mbo.modules.transitions_manager' - - '@translator' + PrestaShop\Module\Mbo\Module\Workflow\TransitionApplier: + autowire: true - mbo.modules.module_status_transition_handler: - class: 'PrestaShop\Module\Mbo\Module\CommandHandler\ModuleStatusTransitionCommandHandler' - arguments: - - '@mbo.modules.repository' - - '@mbo.modules.actions_manager' - - '@mbo.modules.builder' - - '@mbo.modules.transition_builder' - - '@mbo.modules.transition_applier' + PrestaShop\Module\Mbo\Module\CommandHandler\ModuleStatusTransitionCommandHandler: + autowire: true diff --git a/config/services/api/repository.yml b/config/services/api/repository.yml index 3bca65766..c824739c1 100644 --- a/config/services/api/repository.yml +++ b/config/services/api/repository.yml @@ -3,4 +3,4 @@ services: public: true PrestaShop\Module\Mbo\Api\Repository\ModuleRepository: - class: PrestaShop\Module\Mbo\Api\Repository\ModuleRepository + autowire: true diff --git a/config/services/cdc.yml b/config/services/cdc.yml old mode 100644 new mode 100755 index ae9c88ec1..0e05e3fd4 --- a/config/services/cdc.yml +++ b/config/services/cdc.yml @@ -2,12 +2,11 @@ services: _defaults: public: true - mbo.cdc.context_builder: - class: PrestaShop\Module\Mbo\Service\View\ContextBuilder + PrestaShop\Module\Mbo\Service\View\ContextBuilder: + autowire: true arguments: - - '@prestashop.adapter.legacy.context' - - '@prestashop.core.admin.module.repository' - - '@router' - - '@doctrine.cache.provider' - - '@mbo.security.admin_authentication.provider' - - '@mbo.accounts.data_provider' + $router: '@prestashop.router' + $cacheProvider: '@Doctrine\Common\Cache\Psr6\DoctrineProvider' + + mbo.cdc.context_builder: + alias: PrestaShop\Module\Mbo\Service\View\ContextBuilder \ No newline at end of file diff --git a/config/services/distribution.yml b/config/services/distribution.yml index 2e4759c0d..bac1df0c7 100644 --- a/config/services/distribution.yml +++ b/config/services/distribution.yml @@ -5,29 +5,32 @@ services: _defaults: public: true - mbo.doctrine.cache.adapter: - class: Symfony\Component\Cache\Adapter\FilesystemAdapter + mbo_doctrine_cache_provider: '@Doctrine\Common\Cache\Psr6\DoctrineProvider' + + Symfony\Component\Cache\Adapter\FilesystemAdapter: + autowire: true arguments: - - '' - - 0 - - "%ps_cache_dir%%/ps_mbo" + $namespace: '' + $defaultLifetime: 0 + $directory: "%ps_cache_dir%%/ps_mbo" - mbo.doctrine.cache.provider: - class: Symfony\Component\Cache\DoctrineProvider + Doctrine\Common\Cache\Psr6\DoctrineProvider: + autowire: true + autoconfigure: true + factory: [ Doctrine\Common\Cache\Psr6\DoctrineProvider, wrap ] arguments: - - "@mbo.doctrine.cache.adapter" + $pool: '@Symfony\Component\Cache\Adapter\FilesystemAdapter' # Distribution API Client - mbo.cdc.client.distribution_api: - class: PrestaShop\Module\Mbo\Distribution\Client + PrestaShop\Module\Mbo\Distribution\Client: + autowire: true arguments: - - "@mbo.distribution_api.client.http" - - '@mbo.doctrine.cache.provider' + $httpClient: '@mbo.distribution_api.client.http' + $cacheProvider: '@Doctrine\Common\Cache\Psr6\DoctrineProvider' # Distribution API Client with addons user - mbo.cdc.client.connected_distribution_api: - class: PrestaShop\Module\Mbo\Distribution\ConnectedClient + PrestaShop\Module\Mbo\Distribution\ConnectedClient: + autowire: true arguments: - - "@mbo.distribution_api.client.http" - - '@mbo.doctrine.cache.provider' - - '@=service("mbo.addons.user.provider").getUser()' + $httpClient: '@mbo.distribution_api.client.http' + $cacheProvider: '@Doctrine\Common\Cache\Psr6\DoctrineProvider' diff --git a/config/services/eventbus.yml b/config/services/eventbus.yml index 123354761..1531345ab 100755 --- a/config/services/eventbus.yml +++ b/config/services/eventbus.yml @@ -2,8 +2,10 @@ services: _defaults: public: true - mbo.ps_eventbus.installer: - class: 'PrestaShop\Module\Mbo\Service\ModuleInstaller' - public: true + PrestaShop\Module\Mbo\Service\ModuleInstaller: + autowire: true arguments: - "ps_eventbus" + + mbo.ps_eventbus.installer: + alias: PrestaShop\Module\Mbo\Service\ModuleInstaller \ No newline at end of file diff --git a/config/services/modules.yml b/config/services/modules.yml old mode 100644 new mode 100755 index 87b878478..b4f695216 --- a/config/services/modules.yml +++ b/config/services/modules.yml @@ -3,54 +3,46 @@ services: _defaults: public: true - mbo.modules.repository: - class: PrestaShop\Module\Mbo\Module\Repository + PrestaShop\Module\Mbo\Module\Repository: + autowire: true arguments: - - "@mbo.cdc.client.connected_distribution_api" - - "@mbo.modules.builder" - - "@logger" - - "@=service('translator').getLocale()" - - "@doctrine.cache.provider" - - "@=service('prestashop.adapter.legacy.configuration').get('_DB_PREFIX_')" - - "@mbo.security.admin_authentication.provider" - - mbo.modules.filters.factory: - class: PrestaShop\Module\Mbo\Module\FiltersFactory - - mbo.modules.collection.factory: - class: PrestaShop\Module\Mbo\Module\CollectionFactory - - mbo.modules.builder: - class: PrestaShop\Module\Mbo\Module\ModuleBuilder - arguments: - - '@router' - - "@logger" - - "@=service('prestashop.adapter.legacy.configuration').get('_PS_MODULE_DIR_')" + $cacheProvider: '@Doctrine\Common\Cache\Psr6\DoctrineProvider' + $localeCode: "@=service('translator').getLocale()" + $dbPrefix: "@=service('prestashop.adapter.legacy.configuration').get('_DB_PREFIX_')" + + PrestaShop\Module\Mbo\Module\FiltersFactory: + autowire: true - mbo.modules.files_manager: - class: PrestaShop\Module\Mbo\Module\FilesManager + PrestaShop\Module\Mbo\Module\CollectionFactory: + autowire: true + + PrestaShop\Module\Mbo\Module\ModuleBuilder: + autowire: true arguments: - - '@mbo.addons.data_provider' - - '@prestashop.module.factory.sourcehandler' + $moduleDirectory: "@=service('prestashop.adapter.legacy.configuration').get('_PS_MODULE_DIR_')" + $router: '@prestashop.router' + + PrestaShop\Module\Mbo\Module\FilesManager: + autowire: true + + PrestaShop\Module\Mbo\Module\ActionsManager: + autowire: true mbo.modules.actions_manager: - class: PrestaShop\Module\Mbo\Module\ActionsManager - arguments: - - '@mbo.modules.files_manager' - - '@mbo.modules.repository' + alias: PrestaShop\Module\Mbo\Module\ActionsManager - mbo.modules.source_handler.addons_url: - class: PrestaShop\Module\Mbo\Module\SourceHandler\AddonsUrlSourceHandler - arguments: - $addonsUrlSourceRetriever: '@mbo.modules.source_retriever.url' - $zipSourceHandler: '@prestashop.module.sourcehandler.zip' + PrestaShop\Module\Mbo\Module\SourceHandler\AddonsUrlSourceHandler: + autowire: true + autoconfigure: true tags: [ core.module.source_handler ] - mbo.modules.helper: - class: PrestaShop\Module\Mbo\Service\ModulesHelper + PrestaShop\Module\Mbo\Service\ModulesHelper: + autowire: true arguments: - - '@mbo.modules.repository' - - '@router' + $router: '@prestashop.router' + + PrestaShop\Module\Mbo\Service\HookExceptionHolder: + autowire: true mbo.hook_exception_holder: - class: PrestaShop\Module\Mbo\Service\HookExceptionHolder + alias: PrestaShop\Module\Mbo\Service\HookExceptionHolder \ No newline at end of file diff --git a/config/services/overrides.yml b/config/services/overrides.yml index 3de3a078d..1a078adff 100644 --- a/config/services/overrides.yml +++ b/config/services/overrides.yml @@ -2,5 +2,7 @@ services: _defaults: public: true - mbo.symfony_cache_clearer: - class: 'PrestaShop\Module\Mbo\Service\MboSymfonyCacheClearer' + PrestaShop\PrestaShop\Core\Cache\Clearer\CacheClearerInterface: '@PrestaShop\Module\Mbo\Service\MboSymfonyCacheClearer' + + PrestaShop\Module\Mbo\Service\MboSymfonyCacheClearer: + autowire: true diff --git a/config/services/security.yml b/config/services/security.yml old mode 100644 new mode 100755 index 96f886412..c1a465e5d --- a/config/services/security.yml +++ b/config/services/security.yml @@ -2,23 +2,21 @@ services: _defaults: public: true - mbo.security.admin_authentication.provider: - class: PrestaShop\Module\Mbo\Api\Security\AdminAuthenticationProvider +# security.authorization_checker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface' + + PrestaShop\Module\Mbo\Api\Security\AdminAuthenticationProvider: + autowire: true arguments: - - '@doctrine.dbal.default_connection' - - "@=service('prestashop.adapter.legacy.context').getContext()" - - '@prestashop.core.crypto.hashing' - - '@doctrine.cache.provider' - - '%database_prefix%' + $context: "@=service('prestashop.adapter.legacy.context').getContext()" + $dbPrefix: '%database_prefix%' + $cacheProvider: '@Doctrine\Common\Cache\Psr6\DoctrineProvider' PrestaShop\Module\Mbo\Api\Security\AuthorizationChecker: - class: PrestaShop\Module\Mbo\Api\Security\AuthorizationChecker + autowire: true arguments: - - '@doctrine.cache.provider' - - '@mbo.cdc.client.distribution_api' - - '@mbo.security.admin_authentication.provider' + $cacheProvider: '@Doctrine\Common\Cache\Psr6\DoctrineProvider' - mbo.security.permission_checker: - class: PrestaShop\Module\Mbo\Security\PermissionChecker - arguments: - - '@prestashop.adapter.legacy.context' + PrestaShop\Module\Mbo\Security\PermissionCheckerInterface: '@PrestaShop\Module\Mbo\Security\PermissionChecker' + + PrestaShop\Module\Mbo\Security\PermissionChecker: + autowire: true diff --git a/config/services/tab.yml b/config/services/tab.yml index f0aec75c2..d72cfe52d 100644 --- a/config/services/tab.yml +++ b/config/services/tab.yml @@ -2,15 +2,12 @@ services: _defaults: public: true - mbo.tab.collection.factory: - class: 'PrestaShop\Module\Mbo\Tab\TabCollectionFactory' - arguments: - - '@mbo.modules.repository' + PrestaShop\Module\Mbo\Tab\TabCollectionFactoryInterface: '@PrestaShop\Module\Mbo\Tab\TabCollectionFactory' - mbo.tab.collection.provider: - class: 'PrestaShop\Module\Mbo\Tab\TabCollectionProvider' - arguments: - - '@prestashop.adapter.legacy.context' - - '@mbo.externalcontent.provider' - - '@mbo.tab.collection.factory' - - '@doctrine.cache.provider' + PrestaShop\Module\Mbo\Tab\TabCollectionFactory: + autowire: true + + PrestaShop\Module\Mbo\Tab\TabCollectionProviderInterface: '@PrestaShop\Module\Mbo\Tab\TabCollectionProvider' + + PrestaShop\Module\Mbo\Tab\TabCollectionProvider: + autowire: true diff --git a/ps_mbo.php b/ps_mbo.php index ae50e9485..e43efecd0 100755 --- a/ps_mbo.php +++ b/ps_mbo.php @@ -34,6 +34,7 @@ use PrestaShop\Module\Mbo\Api\Security\AdminAuthenticationProvider; use PrestaShop\Module\Mbo\Helpers\Config; use PrestaShop\PrestaShop\Adapter\SymfonyContainer; +use PrestaShop\PrestaShop\Core\Module\ModuleRepository; use PrestaShopBundle\Event\ModuleManagementEvent; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Dotenv\Dotenv; @@ -101,7 +102,7 @@ public function __construct() $this->need_instance = 0; $this->ps_versions_compliancy = [ 'min' => '8.0.2', - 'max' => '8.99.99', + 'max' => '9.99.99', ]; parent::__construct(); @@ -131,7 +132,7 @@ public function __construct() public function install(): bool { try { - $this->getService('mbo.ps_accounts.installer')->install(); + $this->get(PrestaShop\PsAccountsInstaller\Installer\Installer::class)->install(); } catch (Exception $e) { ErrorHelper::reportError($e); } @@ -182,7 +183,7 @@ public function uninstall() $this->uninstallTables(); - /** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface $eventDispatcher */ + /** @var \Symfony\Component\EventDispatcher\EventDispatcher $eventDispatcher */ $eventDispatcher = $this->get('event_dispatcher'); if (!$eventDispatcher->hasListeners(ModuleManagementEvent::UNINSTALL)) { return true; @@ -191,7 +192,7 @@ public function uninstall() // Execute them first foreach ($eventDispatcher->getListeners(ModuleManagementEvent::UNINSTALL) as $listener) { if ($listener[0] instanceof ModuleManagementEventSubscriber) { - $legacyModule = $this->get('prestashop.core.admin.module.repository')->getModule('ps_mbo'); + $legacyModule = $this->get(ModuleRepository::class)->getModule('ps_mbo'); $listener[0]->{(string)$listener[1]}(new ModuleManagementEvent($legacyModule)); } } @@ -355,12 +356,12 @@ public function getAdminAuthenticationProvider(): AdminAuthenticationProvider $this->container = SymfonyContainer::getInstance(); } - return null !== $this->container && $this->container->has('mbo.security.admin_authentication.provider') ? - $this->get('mbo.security.admin_authentication.provider') : + return null !== $this->container && $this->container->has(AdminAuthenticationProvider::class) ? + $this->get(AdminAuthenticationProvider::class) : new AdminAuthenticationProvider( $this->get('doctrine.dbal.default_connection'), $this->context, - $this->get('prestashop.core.crypto.hashing'), + $this->get('hashing'), $this->get('doctrine.cache.provider'), $this->container->getParameter('database_prefix') ); @@ -395,7 +396,7 @@ public function installTables(?string $table = null): bool public function getAccountsDataProvider(): ?AccountsDataProvider { try { - return $this->getService('mbo.accounts.data_provider'); + return $this->get(AccountsDataProvider::class); } catch (\Exception $e) { ErrorHelper::reportError($e); return null; @@ -454,13 +455,14 @@ private function uninstallTables(): bool */ private function loadEnv(): void { - $dotenv = new Dotenv(true); + $dotenv = new Dotenv(); + $dotenv->usePutenv(); $dotenv->loadEnv(__DIR__ . '/.env'); } private function isPsAccountEnabled(): bool { - $accountsInstaller = $this->get('mbo.ps_accounts.installer'); + $accountsInstaller = $this->get(\PrestaShop\PsAccountsInstaller\Installer\Installer::class); return null !== $accountsInstaller && $accountsInstaller->isModuleEnabled(); } diff --git a/src/Addons/ApiClient.php b/src/Addons/ApiClient.php index 0b06c36c0..cc3b57d41 100644 --- a/src/Addons/ApiClient.php +++ b/src/Addons/ApiClient.php @@ -25,6 +25,7 @@ use GuzzleHttp\Exception\GuzzleException; use PrestaShop\Module\Mbo\Helpers\AddonsApiHelper; use PrestaShop\Module\Mbo\Helpers\ErrorHelper; +use Psr\Http\Client\ClientInterface; use stdClass; class ApiClient @@ -71,7 +72,7 @@ class ApiClient /** * @param Client $httpClient */ - public function __construct(Client $httpClient) + public function __construct(ClientInterface $httpClient) { $this->httpClient = $httpClient; } diff --git a/src/Addons/Subscriber/ModuleManagementEventSubscriber.php b/src/Addons/Subscriber/ModuleManagementEventSubscriber.php index c44713f5a..f279fc36d 100644 --- a/src/Addons/Subscriber/ModuleManagementEventSubscriber.php +++ b/src/Addons/Subscriber/ModuleManagementEventSubscriber.php @@ -126,12 +126,6 @@ public static function getSubscribedEvents(): array ['clearCatalogCache'], ['onDisable'], ], - ModuleManagementEvent::ENABLE_MOBILE => [ - ['onEnableOnMobile'], - ], - ModuleManagementEvent::DISABLE_MOBILE => [ - ['onDisableOnMobile'], - ], ModuleManagementEvent::UPGRADE => [ ['clearCatalogCache'], ['onUpgrade'], @@ -192,16 +186,6 @@ public function onDisable(ModuleManagementEvent $event): void $this->logEvent(ModuleManagementEvent::DISABLE, $event); } - public function onEnableOnMobile(ModuleManagementEvent $event): void - { - $this->logEvent(ModuleManagementEvent::ENABLE_MOBILE, $event); - } - - public function onDisableOnMobile(ModuleManagementEvent $event): void - { - $this->logEvent(ModuleManagementEvent::DISABLE_MOBILE, $event); - } - public function onUpgrade(ModuleManagementEvent $event): void { $this->logEvent(ModuleManagementEvent::UPGRADE, $event); diff --git a/src/Addons/User/AddonsUser.php b/src/Addons/User/AddonsUser.php index 47c04779d..02e23afcf 100644 --- a/src/Addons/User/AddonsUser.php +++ b/src/Addons/User/AddonsUser.php @@ -22,7 +22,7 @@ namespace PrestaShop\Module\Mbo\Addons\User; use PrestaShop\Module\Mbo\Accounts\Provider\AccountsDataProvider; -use Symfony\Component\HttpFoundation\Session\SessionInterface; +use Symfony\Component\HttpFoundation\RequestStack; /** * This class will read user information stored in cookies @@ -30,20 +30,20 @@ class AddonsUser implements UserInterface { /** - * @var SessionInterface + * @var AccountsDataProvider */ - private $session; + private $accountsDataProvider; /** - * @var AccountsDataProvider + * @var RequestStack */ - private $accountsDataProvider; + private $requestStack; public function __construct( - SessionInterface $session, + RequestStack $requestStack, AccountsDataProvider $accountsDataProvider ) { - $this->session = $session; + $this->requestStack = $requestStack; $this->accountsDataProvider = $accountsDataProvider; } @@ -116,7 +116,7 @@ public function getAccountsShopUuid(): ?string */ private function getAccountsTokenFromSession() { - return $this->session->get('accounts_token'); + return $this->requestStack->getSession()->get('accounts_token'); } /** diff --git a/src/Api/Controller/AbstractAdminApiController.php b/src/Api/Controller/AbstractAdminApiController.php index 44eb6167f..4995e7d7c 100755 --- a/src/Api/Controller/AbstractAdminApiController.php +++ b/src/Api/Controller/AbstractAdminApiController.php @@ -70,7 +70,7 @@ public function __construct() { parent::__construct(); - $this->adminAuthenticationProvider = $this->module->get('mbo.security.admin_authentication.provider'); + $this->adminAuthenticationProvider = $this->module->get(AdminAuthenticationProvider::class); $this->authorizationChecker = $this->module->get(AuthorizationChecker::class); $this->logger = $this->module->get('logger'); } diff --git a/src/Controller/Admin/AddonsController.php b/src/Controller/Admin/AddonsController.php index d73124c9f..b4d3ed138 100644 --- a/src/Controller/Admin/AddonsController.php +++ b/src/Controller/Admin/AddonsController.php @@ -26,12 +26,12 @@ use PrestaShop\Module\Mbo\Module\Exception\ModuleUpgradeNotNeededException; use PrestaShop\PrestaShop\Core\Module\ModuleManager; use PrestaShop\PrestaShop\Core\Module\ModuleRepository; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; +use PrestaShopBundle\Controller\Admin\PrestaShopAdminController; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Response; -class AddonsController extends FrameworkBundleAdminController +class AddonsController extends PrestaShopAdminController { /** * @var RequestStack diff --git a/src/Controller/Admin/ModuleCatalogController.php b/src/Controller/Admin/ModuleCatalogController.php index 8f0e23b58..61363686f 100755 --- a/src/Controller/Admin/ModuleCatalogController.php +++ b/src/Controller/Admin/ModuleCatalogController.php @@ -1,4 +1,5 @@ Modules > Modules Catalog" page display. */ -class ModuleCatalogController extends ModuleAbstractController +class ModuleCatalogController extends PrestaShopAdminController { public const CONTROLLER_NAME = 'ADMINMODULESSF'; + + /** + * @var Toolbar + */ + private $addonsToolbar; + + /** + * @var ContextBuilder + */ + private $contextBuilder; + + /** + * @var ModuleManager + */ + private $moduleManager; + + /** + * @var PsAccounts + */ + private $psAccountsFacade; + + /** + * @var Installer + */ + private $psAccountsInstaller; + + /** + * @var ModuleInstaller + */ + private $psEventbusInstaller; + + public function __construct( + Toolbar $addonsToolbar, + ContextBuilder $contextBuilder, + ModuleManager $moduleManager, + PsAccounts $psAccountsFacade, + Installer $psAccountsInstaller, + ModuleInstaller $psEventbusInstaller + ) { + $this->addonsToolbar = $addonsToolbar; + $this->contextBuilder = $contextBuilder; + $this->moduleManager = $moduleManager; + $this->psAccountsFacade = $psAccountsFacade; + $this->psAccountsInstaller = $psAccountsInstaller; + $this->psEventbusInstaller = $psEventbusInstaller; + } /** * Module Catalog page @@ -67,33 +124,30 @@ public function indexAction(): Response $urlAccountsCdn = ''; try { - $accountsFacade = $this->get('mbo.ps_accounts.facade'); - $accountsService = $accountsFacade->getPsAccountsService(); + $accountsService = $this->psAccountsFacade->getPsAccountsService(); if ($this->ensurePsAccountIsEnabled()) $this->ensurePsEventbusEnabled(); } catch (\PrestaShop\PsAccountsInstaller\Installer\Exception\InstallerException $e) { - $accountsInstaller = $this->get('mbo.ps_accounts.installer'); // Seems the module is not here, try to install it - $accountsInstaller->install(); - $accountsFacade = $this->get('mbo.ps_accounts.facade'); + $this->psAccountsInstaller->install(); try { - $accountsService = $accountsFacade->getPsAccountsService(); - } catch (\Exception $e) { + $accountsService = $this->psAccountsFacade->getPsAccountsService(); + } catch (Exception $e) { // Installation seems to not work properly - $accountsService = $accountsFacade = null; + $accountsService = null; ErrorHelper::reportError($e); } } - if (null !== $accountsFacade && null !== $accountsService) { + if (null !== $accountsService) { try { \Media::addJsDef([ - 'contextPsAccounts' => $accountsFacade->getPsAccountsPresenter() + 'contextPsAccounts' => $this->psAccountsFacade->getPsAccountsPresenter() ->present('ps_mbo'), ]); // Retrieve the PrestaShop Account CDN $urlAccountsCdn = $accountsService->getAccountsCdn(); - } catch (\Exception $e) { + } catch (Exception $e) { ErrorHelper::reportError($e); } } @@ -101,8 +155,8 @@ public function indexAction(): Response return $this->render( '@Modules/ps_mbo/views/templates/admin/controllers/module_catalog/catalog.html.twig', [ - 'layoutHeaderToolbarBtn' => $this->get('mbo.addons.toolbar')->getToolbarButtons(), - 'layoutTitle' => $this->trans('Marketplace', 'Modules.Mbo.Modulescatalog'), + 'layoutHeaderToolbarBtn' => $this->addonsToolbar->getToolbarButtons(), + 'layoutTitle' => $this->trans('Marketplace', [], 'Modules.Mbo.Modulescatalog'), 'requireAddonsSearch' => true, 'requireBulkActions' => false, 'showContentHeader' => true, @@ -110,10 +164,11 @@ public function indexAction(): Response 'help_link' => $this->generateSidebarLink('AdminModules'), 'requireFilterStatus' => false, 'level' => $this->authorizationLevel(static::CONTROLLER_NAME), - 'shop_context' => $this->get('mbo.cdc.context_builder')->getViewContext(), + 'shop_context' => $this->contextBuilder->getViewContext(), 'urlAccountsCdn' => $urlAccountsCdn, 'errorMessage' => $this->trans( 'You do not have permission to add this.', + [], 'Admin.Notifications.Error' ), ] + $extraParams @@ -134,21 +189,53 @@ public function cdcErrorAction(): Response private function ensurePsAccountIsEnabled(): bool { - $accountsInstaller = $this->get('mbo.ps_accounts.installer'); - if (!$accountsInstaller) return false; + if (version_compare(_PS_VERSION_, "9.0.0", ">=")) return false; - $accountsEnabled = $accountsInstaller->isModuleEnabled(); + if (!$this->psAccountsInstaller) return false; + + $accountsEnabled = $this->psAccountsInstaller->isModuleEnabled(); if ($accountsEnabled) return true; - $moduleManager = $this->get('prestashop.module.manager'); - return $moduleManager->enable($accountsInstaller->getModuleName()); + return $this->moduleManager->enable($this->psAccountsInstaller->getModuleName()); } private function ensurePsEventbusEnabled() { - $installer = $this->get('mbo.ps_eventbus.installer'); - if ($installer->install()) { - $installer->enable(); + if (version_compare(_PS_VERSION_, "9.0.0", ">=")) return false; + + if ($this->psEventbusInstaller->install()) { + $this->psEventbusInstaller->enable(); } } + + + /** + * Checks if the attributes are granted against the current authentication token and optionally supplied object. + * + * @param string $controller name of the controller that token is tested against + * + * @return int + * + * @throws LogicException + */ + private function authorizationLevel($controller) + { + if ($this->isGranted(Permission::DELETE, $controller)) { + return Permission::LEVEL_DELETE; + } + + if ($this->isGranted(Permission::CREATE, $controller)) { + return Permission::LEVEL_CREATE; + } + + if ($this->isGranted(Permission::UPDATE, $controller)) { + return Permission::LEVEL_UPDATE; + } + + if ($this->isGranted(Permission::READ, $controller)) { + return Permission::LEVEL_READ; + } + + return 0; + } } diff --git a/src/Controller/Admin/ModuleRecommendedController.php b/src/Controller/Admin/ModuleRecommendedController.php index 421d310c5..b5e1d2277 100644 --- a/src/Controller/Admin/ModuleRecommendedController.php +++ b/src/Controller/Admin/ModuleRecommendedController.php @@ -21,7 +21,9 @@ namespace PrestaShop\Module\Mbo\Controller\Admin; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; +use PrestaShop\Module\Mbo\Service\View\ContextBuilder; +use PrestaShop\Module\Mbo\Tab\TabCollectionProvider; +use PrestaShopBundle\Controller\Admin\PrestaShopAdminController; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\RequestStack; @@ -31,21 +33,34 @@ /** * Responsible of render json data for ajax display of Recommended Modules. */ -class ModuleRecommendedController extends FrameworkBundleAdminController +class ModuleRecommendedController extends PrestaShopAdminController { /** * @var RequestStack */ protected $requestStack; + /** + * @var TabCollectionProvider + */ + private $tabCollectionProvider; + + /** + * @var ContextBuilder + */ + private $contextBuilder; + /** * @param RequestStack $requestStack */ public function __construct( - RequestStack $requestStack + RequestStack $requestStack, + TabCollectionProvider $tabCollectionProvider, + ContextBuilder $contextBuilder ) { - parent::__construct(); $this->requestStack = $requestStack; + $this->tabCollectionProvider = $tabCollectionProvider; + $this->contextBuilder = $contextBuilder; } /** @@ -65,9 +80,9 @@ public function indexAction(): Response return $this->redirectToRoute('admin_mbo_catalog_module', $routeParams); } - $tabCollection = $this->get('mbo.tab.collection.provider')->getTabCollection(); + $tabCollection = $this->tabCollectionProvider->getTabCollection(); $tab = $tabCollection->getTab($tabClassName); - $context = $this->get('mbo.cdc.context_builder')->getRecommendedModulesContext($tab); + $context = $this->contextBuilder->getRecommendedModulesContext($tab); $context['recommendation_format'] = $this->requestStack->getCurrentRequest()->get('recommendation_format'); $response->setData([ 'content' => $this->renderView( diff --git a/src/Controller/Admin/ModuleSelectionController.php b/src/Controller/Admin/ModuleSelectionController.php index 2d58f8d7f..71de64d6f 100644 --- a/src/Controller/Admin/ModuleSelectionController.php +++ b/src/Controller/Admin/ModuleSelectionController.php @@ -21,7 +21,8 @@ namespace PrestaShop\Module\Mbo\Controller\Admin; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; +use PrestaShop\PrestaShop\Core\Security\Permission; +use PrestaShopBundle\Controller\Admin\PrestaShopAdminController; use PrestaShopBundle\Security\Annotation\AdminSecurity; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Response; @@ -30,7 +31,7 @@ /** * Responsible of "Improve > Modules > Modules Catalog > Modules Selection" page display. */ -class ModuleSelectionController extends FrameworkBundleAdminController +class ModuleSelectionController extends PrestaShopAdminController { /** * @var RequestStack diff --git a/src/Controller/Admin/ThemeCatalogController.php b/src/Controller/Admin/ThemeCatalogController.php index cea9d80ea..502a773f0 100644 --- a/src/Controller/Admin/ThemeCatalogController.php +++ b/src/Controller/Admin/ThemeCatalogController.php @@ -21,7 +21,7 @@ namespace PrestaShop\Module\Mbo\Controller\Admin; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; +use PrestaShopBundle\Controller\Admin\PrestaShopAdminController; use PrestaShopBundle\Security\Annotation\AdminSecurity; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Response; @@ -30,7 +30,7 @@ /** * Responsible of "Improve > Design > Themes Catalog" page display. */ -class ThemeCatalogController extends FrameworkBundleAdminController +class ThemeCatalogController extends PrestaShopAdminController { /** * @var RequestStack diff --git a/src/DependencyInjection/ContainerProvider.php b/src/DependencyInjection/ContainerProvider.php index eb8b6f84d..e2ada21a0 100644 --- a/src/DependencyInjection/ContainerProvider.php +++ b/src/DependencyInjection/ContainerProvider.php @@ -89,6 +89,7 @@ public function get(string $containerName): ContainerInterface ])); $loader->load('http_clients.yml'); + $loader->load('addons.yml'); $loader->load('distribution.yml'); $loader->load('accounts.yml'); $loader->load('eventbus.yml'); diff --git a/src/DependencyInjection/ServiceContainer.php b/src/DependencyInjection/ServiceContainer.php index 0415bd021..80a29ad43 100644 --- a/src/DependencyInjection/ServiceContainer.php +++ b/src/DependencyInjection/ServiceContainer.php @@ -69,6 +69,12 @@ private function initContainer(): void ); $containerProvider = new ContainerProvider($this->moduleName, $this->moduleLocalPath, $cacheDirectory); - $this->container = $containerProvider->get(defined('_PS_ADMIN_DIR_') || defined('PS_INSTALLATION_IN_PROGRESS') || PHP_SAPI === 'cli' ? 'admin' : 'front'); + $this->container = $containerProvider->get( + defined('_PS_ADMIN_DIR_') + || defined('PS_INSTALLATION_IN_PROGRESS') + || PHP_SAPI === 'cli' ? + 'admin' + : 'front' + ); } } diff --git a/src/Distribution/BaseClient.php b/src/Distribution/BaseClient.php index 798ab2c90..429376337 100644 --- a/src/Distribution/BaseClient.php +++ b/src/Distribution/BaseClient.php @@ -22,7 +22,7 @@ namespace PrestaShop\Module\Mbo\Distribution; use Doctrine\Common\Cache\CacheProvider; -use GuzzleHttp\Client as HttpClient; +use Psr\Http\Client\ClientInterface as HttpClient; use GuzzleHttp\Exception\GuzzleException; use PrestaShop\Module\Mbo\Helpers\Config; use ps_mbo; diff --git a/src/Distribution/Client.php b/src/Distribution/Client.php index 6fd80f835..39ef3d14c 100644 --- a/src/Distribution/Client.php +++ b/src/Distribution/Client.php @@ -170,7 +170,7 @@ public function trackEvent(array $eventData): void self::HTTP_METHOD_POST, ['form_params' => $eventData] ); - } catch (\Throwable $e) { + } catch (\Exception|GuzzleException $e) { // Do nothing if the tracking fails ErrorHelper::reportError($e); } diff --git a/src/Distribution/ConnectedClient.php b/src/Distribution/ConnectedClient.php index 046dbdeba..408e22097 100644 --- a/src/Distribution/ConnectedClient.php +++ b/src/Distribution/ConnectedClient.php @@ -23,7 +23,8 @@ use Context; use Doctrine\Common\Cache\CacheProvider; -use GuzzleHttp\Client as HttpClient; +use PrestaShop\Module\Mbo\Addons\User\AddonsUserProvider; +use Psr\Http\Client\ClientInterface as HttpClient; use PrestaShop\Module\Mbo\Addons\User\UserInterface; use PrestaShop\Module\Mbo\Helpers\Config; use PrestaShop\Module\Mbo\Helpers\ErrorHelper; @@ -38,12 +39,15 @@ class ConnectedClient extends BaseClient /** * @param HttpClient $httpClient * @param CacheProvider $cacheProvider - * @param UserInterface $user + * @param AddonsUserProvider $addonsUserProvider */ - public function __construct(HttpClient $httpClient, CacheProvider $cacheProvider, UserInterface $user) - { + public function __construct( + HttpClient $httpClient, + CacheProvider $cacheProvider, + AddonsUserProvider $addonsUserProvider + ) { parent::__construct($httpClient, $cacheProvider); - $this->user = $user; + $this->user = $addonsUserProvider->getUser(); } /** diff --git a/src/Module/SourceHandler/AddonsUrlSourceHandler.php b/src/Module/SourceHandler/AddonsUrlSourceHandler.php index 4eb54401a..781b1c90a 100755 --- a/src/Module/SourceHandler/AddonsUrlSourceHandler.php +++ b/src/Module/SourceHandler/AddonsUrlSourceHandler.php @@ -28,10 +28,6 @@ class AddonsUrlSourceHandler implements SourceHandlerInterface { - private const URL_VALIDATION_REGEX = "/^https?:\\/\\/(?:www\\.)?[-a-zA-Z0-9@:%._\\+~#=]{0,256}api-addons\\.prestashop\\.com(?:[-a-zA-Z0-9()@:%_\\+.~#?&\\/=]*)$/"; - - private const ZIP_FILENAME_PATTERN = '/(\w+)\.zip\b/'; - /** * @var ZipSourceHandler */ diff --git a/src/Service/View/ContextBuilder.php b/src/Service/View/ContextBuilder.php index e63654fee..d58c2e33c 100644 --- a/src/Service/View/ContextBuilder.php +++ b/src/Service/View/ContextBuilder.php @@ -173,7 +173,7 @@ private function getCommonContextContent(): array $token = Tools::getValue('token'); } - $refreshUrl = Context::getContext()->link->getAdminLink('apiSecurityPsMbo'); + $refreshUrl = Context::getContext()->link->getAdminLink('ApiSecurityPsMbo'); return [ 'currency' => $this->getCurrencyCode(), diff --git a/src/Traits/HaveConfigurationPage.php b/src/Traits/HaveConfigurationPage.php old mode 100644 new mode 100755 index 8e056fba9..188419e47 --- a/src/Traits/HaveConfigurationPage.php +++ b/src/Traits/HaveConfigurationPage.php @@ -151,7 +151,7 @@ private function saveNewDotenvData(string $envFilePath): string $dotenv->overload($envFilePath); /** @var MboSymfonyCacheClearer $cacheClearer */ - $cacheClearer = $this->get('mbo.symfony_cache_clearer'); + $cacheClearer = $this->get(MboSymfonyCacheClearer::class); $cacheClearer->clear(); $message = '