From 189f098c5d246c57c38a193a40a3ae4b55bdfdf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Schoenenberger?= <54308193+hschoenenberger@users.noreply.github.com> Date: Fri, 29 Nov 2024 10:50:06 +0100 Subject: [PATCH 1/2] [ACCOUNT-2732] refactor: replace module-lib-service-container (#447) * refactor: get rid of module-lib-service-container * refactor: remove useless deps * refactor: create provider files * chore: empty services files * chore: cleanup composer.json * fix: static closures * refactor: early logger injection * refactor: switch to the lightweight-container lib * feat: scoping lightweight-container --- .dir-scoped | 11 +- ...mpose.prestashop@prestashop-flashlight.yml | 2 +- .github/workflows/accounts-qc-php.yml | 68 +- .github/workflows/build-release-publish.yml | 20 +- .zip-contents | 7 +- .zip-excludes | 1 + Makefile | 71 +- README.md | 2 +- composer.json | 28 +- composer.lock | 931 ++---------------- config.bulle.php | 44 + config.dist.php | 48 + config.local.php | 48 + config.preprod.php | 50 + config.prod.php | 40 + config/admin/services.yml | 3 +- config/command.yml | 50 - config/common.yml | 221 ----- config/config.yml.dist | 38 - config/front/services.yml | 3 +- doc/upgrade-strategy.md | 31 + ps_accounts.php | 48 +- scoper.inc.php | 14 +- scripts/bundle-module.sh | 4 +- .../InconsistentAssociationStateException.php | 18 + src/Adapter/Link.php | 53 +- src/Api/Controller/AbstractRestController.php | 5 +- src/DependencyInjection/ContainerProvider.php | 119 --- src/DependencyInjection/ServiceContainer.php | 108 -- .../AdminController/IsAnonymousAllowed.php | 18 + src/Polyfill/Traits/Controller/AjaxRender.php | 19 + src/Provider/ShopProvider.php | 3 +- src/Repository/EmployeeAccountRepository.php | 1 + .../Provider/ApiClientProvider.php | 54 + .../Provider/CommandProvider.php | 90 ++ .../Provider/DefaultProvider.php | 149 +++ .../Provider/OAuth2Provider.php | 58 ++ .../Provider/RepositoryProvider.php | 58 ++ .../Provider/SessionProvider.php | 63 ++ .../PsAccountsServiceContainer.php | 62 ++ .../UpgradeModuleHandlerTest.php | 4 + tests/composer.json | 3 +- tests/composer.lock | 60 +- tests/phpstan/phpstan-PS-1.7.neon | 5 +- 44 files changed, 1183 insertions(+), 1550 deletions(-) create mode 100644 config.bulle.php create mode 100644 config.dist.php create mode 100644 config.local.php create mode 100644 config.preprod.php create mode 100644 config.prod.php delete mode 100644 config/command.yml delete mode 100644 config/common.yml delete mode 100644 config/config.yml.dist create mode 100644 doc/upgrade-strategy.md delete mode 100644 src/DependencyInjection/ContainerProvider.php delete mode 100644 src/DependencyInjection/ServiceContainer.php create mode 100644 src/ServiceContainer/Provider/ApiClientProvider.php create mode 100644 src/ServiceContainer/Provider/CommandProvider.php create mode 100644 src/ServiceContainer/Provider/DefaultProvider.php create mode 100644 src/ServiceContainer/Provider/OAuth2Provider.php create mode 100644 src/ServiceContainer/Provider/RepositoryProvider.php create mode 100644 src/ServiceContainer/Provider/SessionProvider.php create mode 100644 src/ServiceContainer/PsAccountsServiceContainer.php diff --git a/.dir-scoped b/.dir-scoped index ebde8b403..406208e05 100644 --- a/.dir-scoped +++ b/.dir-scoped @@ -1,17 +1,10 @@ -symfony/cache -symfony/config -symfony/dependency-injection -symfony/expression-language -symfony/filesystem -symfony/yaml psr -monolog guzzlehttp league prestashopcorp/oauth2-prestashop +prestashopcorp/lightweight-container lcobucci -prestashop/module-lib-service-container -prestashop/module-lib-cache-directory-provider +monolog ramsey/uuid ralouphie/getallheaders phpseclib/phpseclib/phpseclib diff --git a/.docker/docker-compose.prestashop@prestashop-flashlight.yml b/.docker/docker-compose.prestashop@prestashop-flashlight.yml index b32c3d0c1..6ae49d355 100644 --- a/.docker/docker-compose.prestashop@prestashop-flashlight.yml +++ b/.docker/docker-compose.prestashop@prestashop-flashlight.yml @@ -2,7 +2,7 @@ version: "3.7" services: prestashop: container_name: phpunit -# image: 'prestashop/prestashop-flashlight:1.7.6.9-7.2' +# image: 'prestashop/prestashop-flashlight:1.7.6' image: ${PLATFORM_IMAGE} healthcheck: test: curl --fail http://localhost:80 || exit 1 diff --git a/.github/workflows/accounts-qc-php.yml b/.github/workflows/accounts-qc-php.yml index 7baecb2f3..3cd043182 100755 --- a/.github/workflows/accounts-qc-php.yml +++ b/.github/workflows/accounts-qc-php.yml @@ -34,12 +34,12 @@ jobs: - name: PHP syntax checker 8.1 uses: prestashop/github-action-php-lint/8.1@master with: - folder-to-exclude: "! -path \"./tests/*\" ! -path \"./vendor/symfony/polyfill-*\" ! -path \"./vendor/symfony/config/*\"" + folder-to-exclude: "! -path \"./tests/*\" ! -path \"./vendor/symfony/polyfill-*\"" - name: PHP syntax checker 8.3 uses: prestashop/github-action-php-lint/8.3@master with: - folder-to-exclude: "! -path \"./tests/*\" ! -path \"./vendor/symfony/polyfill-*\" ! -path \"./vendor/symfony/config/*\" ! path \"./vendor/segmentio/analytics-php/*\"" + folder-to-exclude: "! -path \"./tests/*\" ! -path \"./vendor/symfony/polyfill-*\" ! path \"./vendor/segmentio/analytics-php/*\"" php-cs-fixer: name: PHP-CS-FIXER @@ -50,27 +50,8 @@ jobs: - name: Run PHP-CS-Fixer uses: prestashopcorp/github-action-php-cs-fixer@master - phpstan: - name: PHPStan for Prestashop ${{ matrix.presta-versions }} - runs-on: ubuntu-latest - strategy: - matrix: - presta-versions: - - "1.7.7.8-7.1" - - "1.6.1.24-7.1" - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Scoped dependencies - run: make php-scoper - - - name: PHPStan - run: | - make phpstan-${{ matrix.presta-versions }} - phpunit: - name: PHPUNIT for Prestashop ${{ matrix.presta-versions }} + name: Testsuite for Prestashop ${{ matrix.presta-versions }} runs-on: ubuntu-latest strategy: matrix: @@ -104,35 +85,24 @@ jobs: run: | make phpunit-display-logs -# - name: PHPStan -# run: | -# make phpstan - - header-stamp: - name: Check license headers - runs-on: ubuntu-20.04 - steps: - - name: Checkout - uses: actions/checkout@v3 - - - run: make header-stamp-test + - name: PHPStan + if: matrix.presta-versions == '1.6.1.24-7.1' || matrix.presta-versions == '8.1.5-7.4' + run: | + make phpstan -# - name: Cache vendor folder -# uses: actions/cache@v3 -# with: -# path: vendor -# key: php-${{ hashFiles('composer.lock') }} -# -# - name: Cache composer folder -# uses: actions/cache@v3 -# with: -# path: ~/.composer/cache -# key: php-composer-cache -# -# - run: composer install + - name: header-stamp + if: matrix.presta-versions == '1.6.1.24-5.6-fpm-stretch' + run: | + make header-stamp-test + +# header-stamp: +# name: Check license headers +# runs-on: ubuntu-20.04 +# steps: +# - name: Checkout +# uses: actions/checkout@v3 # -# - name: Run Header Stamp in Dry Run mode -# run: php vendor/bin/header-stamp --license=vendor/prestashop/header-stamp/assets/afl.txt --exclude=.github,node_modules,vendor,vendor,tests,_dev --dry-run +# - run: make header-stamp-test notify-earth: if: ${{ github.event.action == 'labeled' && github.event.label.name == 'ready to review' }} diff --git a/.github/workflows/build-release-publish.yml b/.github/workflows/build-release-publish.yml index cb2e5fcdb..95cddd744 100644 --- a/.github/workflows/build-release-publish.yml +++ b/.github/workflows/build-release-publish.yml @@ -101,19 +101,10 @@ jobs: service_account_key: ${{ secrets.G_CREDENTIAL_PRODUCTION }} export_default_credentials: true - - name: Copy env files - run: | - gcloud components install beta - gcloud beta secrets versions access latest --secret="accounts-module-config" > ${{ github.workspace }}/config/config.yml - env: - GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.G_CREDENTIAL_PRODUCTION }} - - name: Prepare the production zip run: | cd ${{ github.workspace }} - sh ./scripts/bundle-module.sh ${{ env.zip_file }} - env: - ENV_FILE: ${{ secrets.PS_ACCOUNTS_ENV_PROD }} + sh ./scripts/bundle-module.sh ${{ env.zip_file }} 'prod' - name: Publish the production zip uses: actions/upload-release-asset@v1.0.1 @@ -148,17 +139,10 @@ jobs: service_account_key: ${{ secrets.G_CREDENTIAL_PREPROD }} export_default_credentials: true - - name: Copy env files - run: | - gcloud components install beta - gcloud beta secrets versions access latest --secret="accounts-module-config" > ${{ github.workspace }}/config/config.yml - env: - GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.G_CREDENTIAL_PREPROD }} - - name: Prepare the preprod zip run: | cd ${{ github.workspace }} - sh ./scripts/bundle-module.sh ${{ env.zip_file }} + sh ./scripts/bundle-module.sh ${{ env.zip_file }} 'preprod' - name: Publish the preprod zip uses: actions/upload-release-asset@v1.0.1 diff --git a/.zip-contents b/.zip-contents index 75aa225b8..05413458d 100644 --- a/.zip-contents +++ b/.zip-contents @@ -1,4 +1,3 @@ -config controllers sql src @@ -6,7 +5,11 @@ translations upgrade vendor views -CHANGELOG.md +config +config.php +config.local.php +config.prod.php +config.preprod.php config.xml LICENSE logo.png diff --git a/.zip-excludes b/.zip-excludes index 837d650d4..f6cbd7edc 100644 --- a/.zip-excludes +++ b/.zip-excludes @@ -5,6 +5,7 @@ *.idea/* *tests/* *config/config.yml.* +*config.*.php *.bak/* *.md/* *composer.* diff --git a/Makefile b/Makefile index 6c25b4fb7..4bfbdd606 100644 --- a/Makefile +++ b/Makefile @@ -8,8 +8,8 @@ MODULE ?= $(shell basename ${PWD}) CURRENT_UID := $(shell id -u) CURRENT_GID := $(shell id -g) WORKDIR ?= . -PS_VERSION ?= base-8.2-fpm-alpine -TESTING_IMAGE ?= prestashop/prestashop-flashlight:${PS_VERSION} +TESTING_IMAGE_TAG ?= base-8.2-fpm-alpine +TESTING_IMAGE ?= prestashop/prestashop-flashlight:${TESTING_IMAGE_TAG} default: bundle @@ -32,8 +32,8 @@ version: # PLATFORM PLATFORM_REPO ?= prestashop/prestashop-flashlight -PLATFORM_REPO_TAG ?= 8.1.5-7.4 -PLATFORM_IMAGE ?= ${PLATFORM_REPO}:${PHPUNIT_TAG} +PLATFORM_TAG ?= 8.1.5-7.4 +PLATFORM_IMAGE ?= ${PLATFORM_REPO}:${PLATFORM_TAG} PLATFORM_COMPOSE_FILE ?= docker-compose.flashlight.yml COMPOSER_FILE ?= composer.json @@ -57,9 +57,10 @@ platform-stop: platform-restart: platform-stop platform-start -platform-module-config: +.PHONY: config.php +config.php: @docker exec -w ${CONTAINER_INSTALL_DIR} phpunit \ - sh -c "if [ ! -f ./config/config.yml ]; then cp ./config/config.yml.dist ./config/config.yml; fi" + sh -c "if [ ! -f ./config.php ]; then cp ./config.dist.php ./config.php; fi" platform-module-version: @docker exec -w ${CONTAINER_INSTALL_DIR} phpunit \ @@ -70,15 +71,18 @@ platform-phpstan-config: @docker exec -w ${CONTAINER_INSTALL_DIR}/tests phpunit \ sh -c "if [ -f ./phpstan/${NEON_FILE} ]; then cp ./phpstan/${NEON_FILE} ./phpstan/phpstan.neon; fi" -platform-module-install: tests/vendor platform-phpstan-config platform-module-config platform-module-version - -@docker exec phpunit sh -c "if [ -f ./bin/console ]; then php -d memory_limit=-1 ./bin/console prestashop:module install ps_accounts; fi" - -@docker exec phpunit sh -c "if [ ! -f ./bin/console ]; then php -d memory_limit=-1 ./modules/ps_accounts/tests/install-module.php; fi" +platform-module-install: tests/vendor platform-phpstan-config config.php platform-module-version + @docker exec phpunit sh -c "if [ -f ./bin/console ]; then php -d memory_limit=-1 ./bin/console prestashop:module install ps_accounts; fi" + @docker exec phpunit sh -c "if [ ! -f ./bin/console ]; then php -d memory_limit=-1 ./modules/ps_accounts/tests/install-module.php; fi" platform-fix-permissions: @docker exec phpunit sh -c "if [ -d ./var ]; then chown -R www-data:www-data ./var; fi" @docker exec phpunit sh -c "if [ -d ./cache ]; then chown -R www-data:www-data ./cache; fi" # PS1.6 @docker exec phpunit sh -c "if [ -d ./log ]; then chown -R www-data:www-data ./log; fi" # PS1.6 +#platform-status: +# COMPOSER=composer71.json ./composer.phar outdated --locked -m --working-dir=./tests/ + #phpunit-xdebug: # -@docker exec phpunit sh -c "docker-php-ext-enable xdebug" @@ -96,7 +100,7 @@ define build-platform $(eval neonfile = $(if $(neonfile:-=),$(neonfile),${NEON_FILE})) PLATFORM_REPO=$(repo) \ - PHPUNIT_TAG=$(tag) \ + PLATFORM_TAG=$(tag) \ PLATFORM_COMPOSE_FILE=.docker/$(shell echo 'docker-compose.'$(repo)'.yml' | sed 's/\//@/') \ COMPOSER_FILE=${composer} \ NEON_FILE=${neonfile} \ @@ -135,6 +139,9 @@ platform-1.7.8.5-7.4: platform-8.1.5-7.4: $(call build-platform,$@) +platform-8.2.0-8.1: + $(call build-platform,$@) + platform-nightly: $(call build-platform,$@) @@ -181,6 +188,24 @@ phpstan: --memory-limit=-1 \ --configuration=./phpstan/phpstan.neon +############## +# HEADER-STAMP + +header-stamp-test: + @docker exec -w ${CONTAINER_INSTALL_DIR} \ + phpunit ./tests/vendor/bin/header-stamp \ + --target="${WORKDIR}" \ + --license=./tests/vendor/prestashop/header-stamp/assets/afl.txt \ + --exclude=.github,node_modules,vendor,dist,tests,_dev \ + --dry-run + +header-stamp: + @docker exec -w ${CONTAINER_INSTALL_DIR} \ + phpunit ./tests/vendor/bin/header-stamp \ + --target="${WORKDIR}" \ + --license=./tests/vendor/prestashop/header-stamp/assets/afl.txt \ + --exclude=.github,node_modules,vendor,dist,tests,_dev + #phpstan16: NEON_FILE := phpstan-PS-1.6.neon #phpstan16: phpstan @@ -205,7 +230,7 @@ phpunit-nightly: platform-nightly phpunit #"latest", "1.7.6.5", "1.6.1.21" phpstan-1.6.1.24-7.1: platform-1.6.1.24-7.1 phpstan -phpstan-1.7.7.8-7.1: platform-1.7.7.8-7.1 phpstan +phpstan-8.1.5-7.4: platform-8.1.5-7.4 phpstan php-cs-fixer-test-1.6.1.24-5.6-fpm-stretch: platform-1.6.1.24-5.6-fpm-stretch platform-php-cs-fixer-test php-cs-fixer-1.6.1.24-5.6-fpm-stretch: platform-1.6.1.24-5.6-fpm-stretch platform-php-cs-fixer @@ -255,13 +280,13 @@ BUNDLE_ZIP ?= # ex: ps_accounts_flavor.zip BUNDLE_VERSION ?= $(shell grep "" config.xml | sed 's/^.*\([0-9]\+\.[0-9]\+\.[0-9]\+\).*/\1/') BUNDLE_JS ?= views/js/app.${BUNDLE_VERSION}.js -bundle: php-scoper config/config.yml build-front +bundle: php-scoper build-front @./scripts/bundle-module.sh "${BUNDLE_ZIP}" "${BUNDLE_ENV}" -bundle-prod: php-scoper config/config.yml.prod build-front +bundle-prod: php-scoper config.php.prod build-front @./scripts/bundle-module.sh "ps_accounts.zip" "prod" -bundle-preprod: php-scoper config/config.yml.preprod build-front +bundle-preprod: php-scoper config.php.preprod build-front @./scripts/bundle-module.sh "ps_accounts_preprod.zip" "preprod" define build_front @@ -294,15 +319,15 @@ autoindex: COMPOSER_FILE := composer56.json autoindex: tests/vendor ${PHP} ./tests/vendor/bin/autoindex prestashop:add:index "${WORKDIR}" -HEADER_STAMP_DRY_RUN ?= '' -header-stamp: COMPOSER_FILE := composer56.json -header-stamp: tests/vendor - ${PHP} -d error_reporting=1 ./tests/vendor/bin/header-stamp --target="${WORKDIR}" ${HEADER_STAMP_DRY_RUN} \ - --license="assets/afl.txt" --exclude=".github,node_modules,vendor,vendor,tests,_dev" - -header-stamp-test: COMPOSER_FILE := composer56.json -header-stamp-test: HEADER_STAMP_DRY_RUN := '--dry-run' -header-stamp-test: tests/vendor header-stamp +#HEADER_STAMP_DRY_RUN ?= '' +#header-stamp: COMPOSER_FILE := composer56.json +#header-stamp: tests/vendor +# ${PHP} -d error_reporting=1 ./tests/vendor/bin/header-stamp --target="${WORKDIR}" ${HEADER_STAMP_DRY_RUN} \ +# --license="assets/afl.txt" --exclude=".github,node_modules,vendor,vendor,tests,_dev" +# +#header-stamp-test: COMPOSER_FILE := composer56.json +#header-stamp-test: HEADER_STAMP_DRY_RUN := '--dry-run' +#header-stamp-test: tests/vendor header-stamp ########################################################## COMPOSER_OPTIONS ?= --prefer-dist -o --no-dev --quiet diff --git a/README.md b/README.md index 427ae35cc..75a207ae4 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Source Code](https://img.shields.io/badge/source-PrestaShopCorp/ps_accounts-blue.svg?style=flat-square)](https://github.com/PrestaShopCorp/ps_accounts) [![Latest Version](https://img.shields.io/github/release/PrestaShopCorp/ps_accounts.svg?style=flat-square)](https://github.com/PrestaShopCorp/ps_accounts/releases) -[![Software License](https://img.shields.io/badge/license-OSL-brightgreen.svg?style=flat-square)](https://github.com/PrestaShopCorp/oauth2-prestashop/blob/main/LICENSE) +[![Software License](https://img.shields.io/badge/license-OSL-brightgreen.svg?style=flat-square)](https://github.com/PrestaShopCorp/ps_accounts/blob/main/LICENSE) [![Build Status](https://img.shields.io/github/actions/workflow/status/PrestaShopCorp/ps_accounts/.github/workflows/php.yml?label=CI&logo=github&style=flat-square)](https://github.com/PrestaShopCorp/ps_accounts/actions?query=workflow%3ACI) The module **ps_accounts** is the interface between your module and PrestaShop's services. It manages: diff --git a/composer.json b/composer.json index 3eab51673..d6d43f0c5 100644 --- a/composer.json +++ b/composer.json @@ -28,19 +28,10 @@ "PrestaShop\\Module\\PsAccounts\\Vendor\\League\\OAuth2\\Client\\": "vendor/league/oauth2-client/src", "PrestaShop\\Module\\PsAccounts\\Vendor\\Lcobucci\\JWT\\": "vendor/lcobucci/jwt/src", "PrestaShop\\Module\\PsAccounts\\Vendor\\phpseclib\\": "vendor/phpseclib/phpseclib/phpseclib", - "PrestaShop\\Module\\PsAccounts\\Vendor\\Psr\\Cache\\": "vendor/psr/cache/src", - "PrestaShop\\Module\\PsAccounts\\Vendor\\Psr\\Container\\": "vendor/psr/container/src", "PrestaShop\\Module\\PsAccounts\\Vendor\\Psr\\Http\\Message\\": "vendor/psr/http-message/src", "PrestaShop\\Module\\PsAccounts\\Vendor\\Psr\\Log\\": "vendor/psr/log/Psr/Log", - "PrestaShop\\Module\\PsAccounts\\Vendor\\Psr\\SimpleCache\\": "vendor/psr/simple-cache/src", "PrestaShop\\Module\\PsAccounts\\Vendor\\Ramsey\\Uuid\\": "vendor/ramsey/uuid/src", - "PrestaShop\\Module\\PsAccounts\\Vendor\\Symfony\\Component\\Cache\\": "vendor/symfony/cache", - "PrestaShop\\Module\\PsAccounts\\Vendor\\Symfony\\Component\\DependencyInjection\\": "vendor/symfony/dependency-injection", - "PrestaShop\\Module\\PsAccounts\\Vendor\\Symfony\\Component\\ExpressionLanguage\\": "vendor/symfony/expression-language", - "PrestaShop\\Module\\PsAccounts\\Vendor\\Symfony\\Component\\Filesystem\\": "vendor/symfony/filesystem", - "PrestaShop\\Module\\PsAccounts\\Vendor\\Symfony\\Component\\Yaml\\": "vendor/symfony/yaml", - "PrestaShop\\Module\\PsAccounts\\Vendor\\PrestaShop\\ModuleLibServiceContainer\\": "vendor/prestashop/module-lib-service-container/src", - "PrestaShop\\Module\\PsAccounts\\Vendor\\PrestaShop\\ModuleLibCacheDirectoryProvider\\": "vendor/prestashop/module-lib-cache-directory-provider/src" + "PrestaShop\\Module\\PsAccounts\\Vendor\\PrestaShopCorp\\LightweightContainer\\": "vendor/prestashopcorp/lightweight-container/src" }, "classmap": [ "ps_accounts.php", @@ -53,17 +44,18 @@ "ext-json": "*", "lcobucci/jwt": "^3.3", "monolog/monolog": "^1.25.3", - "prestashop/module-lib-service-container": "^1.2", "sentry/sentry": "^1.0", "segmentio/analytics-php": "^1.8", "ramsey/uuid": "^3.9", "prestashopcorp/oauth2-prestashop": "^2.0", - "guzzlehttp/guzzle": "^6.0" - }, - "scripts": { - "set-license-header": [ - "@php ./vendor/bin/header-stamp --license=\"assets/afl.txt\" --exclude=\".github,node_modules,vendor,vendor,tests,_dev\"" - ] + "guzzlehttp/guzzle": "^6.0", + "prestashopcorp/lightweight-container": "dev-main" }, + "repositories": [ + { + "type": "vcs", + "url": "git@github.com:PrestaShopCorp/lightweight-container.git" + } + ], "author": "PrestaShop" -} \ No newline at end of file +} diff --git a/composer.lock b/composer.lock index 313355b74..adb21b00d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f27942fa003bfb9f96ad8f7bf867f954", + "content-hash": "e1e08bc9be7000c8d1553fbbafe15167", "packages": [ { "name": "guzzlehttp/guzzle", @@ -703,107 +703,41 @@ "time": "2024-02-26T04:55:38+00:00" }, { - "name": "prestashop/module-lib-cache-directory-provider", - "version": "v1.0.0", + "name": "prestashopcorp/lightweight-container", + "version": "dev-main", "source": { "type": "git", - "url": "https://github.com/PrestaShopCorp/module-lib-cache-directory-provider.git", - "reference": "34a577b66a7e52ae16d6f40efd1db17290bad453" + "url": "https://github.com/PrestaShopCorp/lightweight-container.git", + "reference": "1f160049867672be909c653e9adcb818d4befd30" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PrestaShopCorp/module-lib-cache-directory-provider/zipball/34a577b66a7e52ae16d6f40efd1db17290bad453", - "reference": "34a577b66a7e52ae16d6f40efd1db17290bad453", + "url": "https://api.github.com/repos/PrestaShopCorp/lightweight-container/zipball/1f160049867672be909c653e9adcb818d4befd30", + "reference": "1f160049867672be909c653e9adcb818d4befd30", "shasum": "" }, "require": { - "php": ">=5.6.0" - }, - "require-dev": { - "phpunit/phpunit": "~5.7" - }, - "type": "project", - "autoload": { - "psr-4": { - "PrestaShop\\ModuleLibCacheDirectoryProvider\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "AFL-3.0" - ], - "authors": [ - { - "name": "PrestaShop SA", - "email": "contact@prestashop.com" - } - ], - "description": "Cache directory provider to use on prestashop modules", - "keywords": [ - "composer", - "modules", - "package", - "prestashop" - ], - "support": { - "issues": "https://github.com/PrestaShopCorp/module-lib-cache-directory-provider/issues", - "source": "https://github.com/PrestaShopCorp/module-lib-cache-directory-provider/tree/master" - }, - "time": "2020-09-08T14:13:23+00:00" - }, - { - "name": "prestashop/module-lib-service-container", - "version": "1.4.0", - "source": { - "type": "git", - "url": "https://github.com/PrestaShopCorp/module-lib-service-container.git", - "reference": "96f4f551b96cffb1f78462cd4722f0d2b057abda" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PrestaShopCorp/module-lib-service-container/zipball/96f4f551b96cffb1f78462cd4722f0d2b057abda", - "reference": "96f4f551b96cffb1f78462cd4722f0d2b057abda", - "shasum": "" - }, - "require": { - "php": ">=5.6.0", - "prestashop/module-lib-cache-directory-provider": "^1.0", - "symfony/config": "^3.4", - "symfony/dependency-injection": "^3.4", - "symfony/expression-language": "^3.4", - "symfony/yaml": "^3.4" - }, - "require-dev": { - "phpunit/phpunit": "~5.7" + "php": ">=5.6" }, + "default-branch": true, "type": "library", "autoload": { "psr-4": { - "PrestaShop\\ModuleLibServiceContainer\\": "src/" + "PrestaShopCorp\\LightweightContainer\\": "src/" } }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "AFL-3.0" - ], "authors": [ { - "name": "PrestaShop SA", - "email": "contact@prestashop.com" + "name": "hschoenenberger", + "email": "herve.schoenenberger@prestashop.com" } ], - "description": "Service container to use on prestashop modules", - "keywords": [ - "composer", - "modules", - "package", - "prestashop" - ], + "description": "No-deps lightweight service container", "support": { - "issues": "https://github.com/PrestaShopCorp/module-lib-service-container/issues", - "source": "https://github.com/PrestaShopCorp/module-lib-service-container/tree/1.4.0" + "source": "https://github.com/PrestaShopCorp/lightweight-container/tree/main", + "issues": "https://github.com/PrestaShopCorp/lightweight-container/issues" }, - "time": "2021-06-01T15:21:20+00:00" + "time": "2024-11-26T14:42:14+00:00" }, { "name": "prestashopcorp/oauth2-prestashop", @@ -861,108 +795,6 @@ }, "time": "2024-05-22T12:33:38+00:00" }, - { - "name": "psr/cache", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/php-fig/cache.git", - "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8", - "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Cache\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for caching libraries", - "keywords": [ - "cache", - "psr", - "psr-6" - ], - "support": { - "source": "https://github.com/php-fig/cache/tree/master" - }, - "time": "2016-08-06T20:24:11+00:00" - }, - { - "name": "psr/container", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/container.git", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Container\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common Container Interface (PHP FIG PSR-11)", - "homepage": "https://github.com/php-fig/container", - "keywords": [ - "PSR-11", - "container", - "container-interface", - "container-interop", - "psr" - ], - "support": { - "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/master" - }, - "time": "2017-02-14T16:28:37+00:00" - }, { "name": "psr/http-message", "version": "1.0.1", @@ -1066,57 +898,6 @@ }, "time": "2021-05-03T11:20:27+00:00" }, - { - "name": "psr/simple-cache", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/php-fig/simple-cache.git", - "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", - "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\SimpleCache\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interfaces for simple caching", - "keywords": [ - "cache", - "caching", - "psr", - "psr-16", - "simple-cache" - ], - "support": { - "source": "https://github.com/php-fig/simple-cache/tree/master" - }, - "time": "2017-10-23T01:57:42+00:00" - }, { "name": "ralouphie/getallheaders", "version": "3.0.3", @@ -1385,47 +1166,42 @@ "time": "2020-02-12T18:38:11+00:00" }, { - "name": "symfony/cache", - "version": "v3.4.47", + "name": "symfony/polyfill-ctype", + "version": "v1.19.0", "source": { "type": "git", - "url": "https://github.com/symfony/cache.git", - "reference": "a7a14c4832760bd1fbd31be2859ffedc9b6ff813" + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "aed596913b70fae57be53d86faa2e9ef85a2297b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/cache/zipball/a7a14c4832760bd1fbd31be2859ffedc9b6ff813", - "reference": "a7a14c4832760bd1fbd31be2859ffedc9b6ff813", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/aed596913b70fae57be53d86faa2e9ef85a2297b", + "reference": "aed596913b70fae57be53d86faa2e9ef85a2297b", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8", - "psr/cache": "~1.0", - "psr/log": "~1.0", - "psr/simple-cache": "^1.0", - "symfony/polyfill-apcu": "~1.1" - }, - "conflict": { - "symfony/var-dumper": "<3.3" - }, - "provide": { - "psr/cache-implementation": "1.0", - "psr/simple-cache-implementation": "1.0" + "php": ">=5.3.3" }, - "require-dev": { - "cache/integration-tests": "dev-master", - "doctrine/cache": "^1.6", - "doctrine/dbal": "^2.4|^3.0", - "predis/predis": "^1.0" + "suggest": { + "ext-ctype": "For best performance" }, "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.19-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, "autoload": { + "files": [ + "bootstrap.php" + ], "psr-4": { - "Symfony\\Component\\Cache\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] + "Symfony\\Polyfill\\Ctype\\": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -1433,22 +1209,24 @@ ], "authors": [ { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony Cache component with PSR-6, PSR-16, and tags", + "description": "Symfony polyfill for ctype functions", "homepage": "https://symfony.com", "keywords": [ - "caching", - "psr6" + "compatibility", + "ctype", + "polyfill", + "portable" ], "support": { - "source": "https://github.com/symfony/cache/tree/v3.4.47" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.19.0" }, "funding": [ { @@ -1464,48 +1242,48 @@ "type": "tidelift" } ], - "time": "2020-10-24T10:57:07+00:00" + "time": "2020-10-23T09:01:57+00:00" }, { - "name": "symfony/config", - "version": "v3.4.47", + "name": "symfony/polyfill-intl-idn", + "version": "v1.19.0", "source": { "type": "git", - "url": "https://github.com/symfony/config.git", - "reference": "bc6b3fd3930d4b53a60b42fe2ed6fc466b75f03f" + "url": "https://github.com/symfony/polyfill-intl-idn.git", + "reference": "4ad5115c0f5d5172a9fe8147675ec6de266d8826" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/bc6b3fd3930d4b53a60b42fe2ed6fc466b75f03f", - "reference": "bc6b3fd3930d4b53a60b42fe2ed6fc466b75f03f", + "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/4ad5115c0f5d5172a9fe8147675ec6de266d8826", + "reference": "4ad5115c0f5d5172a9fe8147675ec6de266d8826", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/filesystem": "~2.8|~3.0|~4.0", - "symfony/polyfill-ctype": "~1.8" - }, - "conflict": { - "symfony/dependency-injection": "<3.3", - "symfony/finder": "<3.3" - }, - "require-dev": { - "symfony/dependency-injection": "~3.3|~4.0", - "symfony/event-dispatcher": "~3.3|~4.0", - "symfony/finder": "~3.3|~4.0", - "symfony/yaml": "~3.0|~4.0" + "php": ">=5.3.3", + "symfony/polyfill-intl-normalizer": "^1.10", + "symfony/polyfill-php70": "^1.10", + "symfony/polyfill-php72": "^1.10" }, "suggest": { - "symfony/yaml": "To use the yaml reference dumper" + "ext-intl": "For best performance" }, "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.19-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, "autoload": { + "files": [ + "bootstrap.php" + ], "psr-4": { - "Symfony\\Component\\Config\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] + "Symfony\\Polyfill\\Intl\\Idn\\": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -1513,18 +1291,30 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "name": "Laurent Bassin", + "email": "laurent@bassin.info" + }, + { + "name": "Trevor Rowbotham", + "email": "trevor.rowbotham@pm.me" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony Config Component", + "description": "Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions", "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "idn", + "intl", + "polyfill", + "portable", + "shim" + ], "support": { - "source": "https://github.com/symfony/config/tree/v3.4.47" + "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.19.0" }, "funding": [ { @@ -1540,476 +1330,24 @@ "type": "tidelift" } ], - "time": "2020-10-24T10:57:07+00:00" + "time": "2020-10-21T09:57:48+00:00" }, { - "name": "symfony/dependency-injection", - "version": "v3.4.47", + "name": "symfony/polyfill-intl-normalizer", + "version": "v1.19.0", "source": { "type": "git", - "url": "https://github.com/symfony/dependency-injection.git", - "reference": "51d2a2708c6ceadad84393f8581df1dcf9e5e84b" + "url": "https://github.com/symfony/polyfill-intl-normalizer.git", + "reference": "8db0ae7936b42feb370840cf24de1a144fb0ef27" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/51d2a2708c6ceadad84393f8581df1dcf9e5e84b", - "reference": "51d2a2708c6ceadad84393f8581df1dcf9e5e84b", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8db0ae7936b42feb370840cf24de1a144fb0ef27", + "reference": "8db0ae7936b42feb370840cf24de1a144fb0ef27", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8", - "psr/container": "^1.0" - }, - "conflict": { - "symfony/config": "<3.3.7", - "symfony/finder": "<3.3", - "symfony/proxy-manager-bridge": "<3.4", - "symfony/yaml": "<3.4" - }, - "provide": { - "psr/container-implementation": "1.0" - }, - "require-dev": { - "symfony/config": "~3.3|~4.0", - "symfony/expression-language": "~2.8|~3.0|~4.0", - "symfony/yaml": "~3.4|~4.0" - }, - "suggest": { - "symfony/config": "", - "symfony/expression-language": "For using expressions in service container configuration", - "symfony/finder": "For using double-star glob patterns or when GLOB_BRACE portability is required", - "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them", - "symfony/yaml": "" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\DependencyInjection\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony DependencyInjection Component", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/dependency-injection/tree/v3.4.47" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-10-24T10:57:07+00:00" - }, - { - "name": "symfony/expression-language", - "version": "v3.4.47", - "source": { - "type": "git", - "url": "https://github.com/symfony/expression-language.git", - "reference": "de38e66398fca1fcb9c48e80279910e6889cb28f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/expression-language/zipball/de38e66398fca1fcb9c48e80279910e6889cb28f", - "reference": "de38e66398fca1fcb9c48e80279910e6889cb28f", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/cache": "~3.1|~4.0", - "symfony/polyfill-php70": "~1.6" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\ExpressionLanguage\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony ExpressionLanguage Component", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/expression-language/tree/v3.4.47" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-10-24T10:57:07+00:00" - }, - { - "name": "symfony/filesystem", - "version": "v3.4.47", - "source": { - "type": "git", - "url": "https://github.com/symfony/filesystem.git", - "reference": "e58d7841cddfed6e846829040dca2cca0ebbbbb3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/e58d7841cddfed6e846829040dca2cca0ebbbbb3", - "reference": "e58d7841cddfed6e846829040dca2cca0ebbbbb3", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/polyfill-ctype": "~1.8" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Filesystem\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Filesystem Component", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/filesystem/tree/v3.4.47" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-10-24T10:57:07+00:00" - }, - { - "name": "symfony/polyfill-apcu", - "version": "v1.19.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-apcu.git", - "reference": "b44b51e7814c23bfbd793a16ead5d7ce43ed23c5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-apcu/zipball/b44b51e7814c23bfbd793a16ead5d7ce43ed23c5", - "reference": "b44b51e7814c23bfbd793a16ead5d7ce43ed23c5", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.19-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Apcu\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting apcu_* functions to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "apcu", - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-apcu/tree/v1.19.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-10-21T09:57:48+00:00" - }, - { - "name": "symfony/polyfill-ctype", - "version": "v1.19.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "aed596913b70fae57be53d86faa2e9ef85a2297b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/aed596913b70fae57be53d86faa2e9ef85a2297b", - "reference": "aed596913b70fae57be53d86faa2e9ef85a2297b", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-ctype": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.19-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], - "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.19.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-10-23T09:01:57+00:00" - }, - { - "name": "symfony/polyfill-intl-idn", - "version": "v1.19.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-intl-idn.git", - "reference": "4ad5115c0f5d5172a9fe8147675ec6de266d8826" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/4ad5115c0f5d5172a9fe8147675ec6de266d8826", - "reference": "4ad5115c0f5d5172a9fe8147675ec6de266d8826", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "symfony/polyfill-intl-normalizer": "^1.10", - "symfony/polyfill-php70": "^1.10", - "symfony/polyfill-php72": "^1.10" - }, - "suggest": { - "ext-intl": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.19-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Intl\\Idn\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Laurent Bassin", - "email": "laurent@bassin.info" - }, - { - "name": "Trevor Rowbotham", - "email": "trevor.rowbotham@pm.me" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "idn", - "intl", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.19.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-10-21T09:57:48+00:00" - }, - { - "name": "symfony/polyfill-intl-normalizer", - "version": "v1.19.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "8db0ae7936b42feb370840cf24de1a144fb0ef27" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8db0ae7936b42feb370840cf24de1a144fb0ef27", - "reference": "8db0ae7936b42feb370840cf24de1a144fb0ef27", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" + "php": ">=5.3.3" }, "suggest": { "ext-intl": "For best performance" @@ -2233,83 +1571,14 @@ } ], "time": "2020-10-23T09:01:57+00:00" - }, - { - "name": "symfony/yaml", - "version": "v3.4.47", - "source": { - "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "88289caa3c166321883f67fe5130188ebbb47094" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/88289caa3c166321883f67fe5130188ebbb47094", - "reference": "88289caa3c166321883f67fe5130188ebbb47094", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/polyfill-ctype": "~1.8" - }, - "conflict": { - "symfony/console": "<3.4" - }, - "require-dev": { - "symfony/console": "~3.4|~4.0" - }, - "suggest": { - "symfony/console": "For validating YAML files using the lint command" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Yaml\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Yaml Component", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/yaml/tree/v3.4.47" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-10-24T10:57:07+00:00" } ], "packages-dev": [], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "prestashopcorp/lightweight-container": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/config.bulle.php b/config.bulle.php new file mode 100644 index 000000000..11a8dc3c0 --- /dev/null +++ b/config.bulle.php @@ -0,0 +1,44 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +return [ + 'ps_accounts.environment' => 'integration', + 'ps_accounts.accounts_api_url' => 'https://accounts-api-prestabulle2.distribution-integration.prestashop.net/', + 'ps_accounts.accounts_ui_url' => 'https://accounts-prestabulle2.distribution-integration.prestashop.net', + 'ps_accounts.sso_account_url' => 'https://prestashop-newsso-staging.appspot.com/login', + 'ps_accounts.sso_resend_verification_email_url' => 'https://prestashop-newsso-staging.appspot.com/account/send-verification-email', + 'ps_accounts.billing_api_url' => 'https://billing-api.distribution-preprod.prestashop.net/', + 'ps_accounts.indirect_channel_api_url' => 'https://indirect-channel-api-preprod.prestashop.net', + 'ps_accounts.sentry_credentials' => 'https://a065bd1f092f8c849e6076fe0640d049@o298402.ingest.us.sentry.io/5354585', + 'ps_accounts.segment_write_key' => 'eYODaH20rT1lMRTTUtAa15BKBlV1XUXQ', + 'ps_accounts.accounts_vue_cdn_url' => 'https://unpkg.com/prestashop_accounts_vue_components@3/dist/psaccountsVue.umd.min.js', + 'ps_accounts.accounts_cdn_url' => 'https://unpkg.com/prestashop_accounts_vue_components@5', + 'ps_accounts.svc_accounts_ui_url' => 'https://accounts.psessentials-integration.net', + 'ps_accounts.oauth2_url' => 'https://oauth-integration.prestashop.com', + //ps_accounts.oauth2_url_authorize' => 'https://oauth-integration.prestashop.com/oauth2/auth' + //ps_accounts.oauth2_url_access_token' => 'https://oauth-integration.prestashop.com/oauth2/token' + //ps_accounts.oauth2_url_resource_owner_details' => 'https://oauth-integration.prestashop.com/userinfo' + //ps_accounts.oauth2_url_session_logout' => 'https://oauth-integration.prestashop.com/oauth2/sessions/logout' + + 'ps_accounts.testimonials_url' => 'https://assets.prestashop3.com/dst/accounts/assets/testimonials.json', + + 'ps_accounts.check_api_ssl_cert' => true, + 'ps_accounts.verify_account_tokens' => true, +]; diff --git a/config.dist.php b/config.dist.php new file mode 100644 index 000000000..8362eaa15 --- /dev/null +++ b/config.dist.php @@ -0,0 +1,48 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +return [ + 'ps_accounts.accounts_api_url' => 'https://accounts-api.prestashop.localhost/', + 'ps_accounts.accounts_ui_url' => 'https://accounts.prestashop.localhost', + 'ps_accounts.sso_api_url' => 'https://auth-preprod.prestashop.com/api/v1/', + 'ps_accounts.sso_account_url' => 'https://authv2-preprod.prestashop.com/login', + 'ps_accounts.sso_resend_verification_email_url' => 'https://auth-preprod.prestashop.com/account/send-verification-email', + 'ps_accounts.billing_api_url' => 'https://billing-api.psessentials-integration.net', + 'ps_accounts.sentry_credentials' => 'https://4c7f6c8dd5aa405b8401a35f5cf26ada@o298402.ingest.sentry.io/5354585', + 'ps_accounts.segment_write_key' => 'UITzSdsFTgYsXaiJG09hsCiupUPwgJQB', + 'ps_accounts.check_api_ssl_cert' => false, + 'ps_accounts.verify_account_tokens' => false, + 'ps_accounts.accounts_vue_cdn_url' => 'https://unpkg.com/prestashop_accounts_vue_components@3/dist/psaccountsVue.umd.min.js', + 'ps_accounts.accounts_cdn_url' => 'https://unpkg.com/prestashop_accounts_vue_components@4/dist/psaccountsVue.umd.min.js', + 'ps_accounts.environment' => 'development', + + // a page to display "Update Your Module" message + 'ps_accounts.svc_accounts_ui_url' => 'https://accounts.psessentials-integration.net', + + // OAuth2 configuration url + 'ps_accounts.oauth2_url' => 'https://oauth.prestashop.localhost', + + // Login page testimonials url + 'ps_accounts.testimonials_url' => 'https://assets.prestashop3.com/dst/accounts/assets/testimonials.json', + + // optional log level (defaults to ERROR) + //ps_accounts.log_level' => !php/const PrestaShop\Module\PsAccounts\Log\Logger::ERROR + 'ps_accounts.log_level' => 'ERROR', +]; diff --git a/config.local.php b/config.local.php new file mode 100644 index 000000000..498dc7f82 --- /dev/null +++ b/config.local.php @@ -0,0 +1,48 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +return [ + 'ps_accounts.environment' => 'development', + 'ps_accounts.accounts_api_url' => 'https://accounts-api.prestashop.local/', + 'ps_accounts.accounts_ui_url' => 'https://accounts.prestashop.local', + 'ps_accounts.sso_api_url' => 'https://auth.prestashop.local/api/', + 'ps_accounts.sso_account_url' => 'https://auth.prestashop.local/login', + 'ps_accounts.sso_resend_verification_email_url' => 'https://auth.prestashop.local/account/send-verification-email', + 'ps_accounts.billing_api_url' => 'https://billing-api.psessentials-integration.net', + 'ps_accounts.indirect_channel_api_url' => 'https://indirect-channel-api-integration.prestashop.net', + 'ps_accounts.sentry_credentials' => 'https://12e8e4574d50b54d878db8ee2c3f8380@o298402.ingest.us.sentry.io/5354585', + '#ps_accounts.segment_write_key' => 'UITzSdsFTgYsXaiJG09hsCiupUPwgJQB', + 'ps_accounts.segment_write_key' => 'eYODaH20rT1lMRTTUtAa15BKBlV1XUXQ', + 'ps_accounts.check_api_ssl_cert' => false, + 'ps_accounts.verify_account_tokens' => false, + 'ps_accounts.accounts_vue_cdn_url' => 'http://prestashop8.docker.localhost/upload/psaccountsVue.umd.min.js', + //ps_accounts.accounts_cdn_url' => 'http://prestashop8.docker.localhost/upload/psaccountsVue.js' + //ps_accounts.accounts_cdn_url' => 'https://unpkg.com/prestashop_accounts_vue_components@5.1.0-test-1/dist/psaccountsVue.js' + 'ps_accounts.accounts_cdn_url' => 'http://localhost:5174/dist/psaccountsVue.js', + + // a page to display "Update Your Module" message + 'ps_accounts.svc_accounts_ui_url' => 'https://accounts.prestashop.local/', + + // OAuth2 setup + 'ps_accounts.oauth2_url' => 'https://oauth.prestashop.local', + + 'ps_accounts.testimonials_url' => 'https://assets.prestashop3.com/dst/accounts/assets/testimonials.json', + 'ps_accounts.log_level' => 'DEBUG', +]; diff --git a/config.preprod.php b/config.preprod.php new file mode 100644 index 000000000..37f9b82de --- /dev/null +++ b/config.preprod.php @@ -0,0 +1,50 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +return [ + 'ps_accounts.segment_write_key' => 'eYODaH20rT1lMRTTUtAa15BKBlV1XUXQ', + 'ps_accounts.accounts_api_url' => 'https://accounts-api.distribution-preprod.prestashop.net/', + 'ps_accounts.accounts_ui_url' => 'https://accounts.distribution-preprod.prestashop.net', + 'ps_accounts.billing_api_url' => 'https://billing-api.distribution-preprod.prestashop.net/', + 'ps_accounts.sso_api_url' => 'https://auth-preprod.prestashop.com/api/v1/', + 'ps_accounts.sso_account_url' => 'https://authv2-preprod.prestashop.com/login', + 'ps_accounts.indirect_channel_api_url' => 'https://indirect-channel-api-preprod.prestashop.net', + 'ps_accounts.segment_api_key' => 'yO1sKx3Xe9upW4bRDoRXEB0TZEXQm2y3', + 'ps_accounts.sso_resend_verification_email_url' => 'https://auth-preprod.prestashop.com/account/send-verification-email', + 'ps_accounts.sentry_credentials' => 'https://a065bd1f092f8c849e6076fe0640d049@o298402.ingest.us.sentry.io/5354585', + 'ps_accounts.accounts_vue_cdn_url' => 'https://unpkg.com/prestashop_accounts_vue_components/dist/psaccountsVue.js', + 'ps_accounts.accounts_cdn_url' => 'https://unpkg.com/prestashop_accounts_vue_components/dist/psaccountsVue.js', + + 'ps_accounts.environment' => 'preprod', + + // whether to check ssl certificate when calling external api + 'ps_accounts.check_api_ssl_cert' => true, + // whether to verify tokens while storing link account + 'ps_accounts.verify_account_tokens' => true, + + // a page to display "Update Your Module" message + 'ps_accounts.svc_accounts_ui_url' => 'https://accounts.psessentials-integration.net', + + 'ps_accounts.oauth2_url' => 'https://oauth-preprod.prestashop.com', + + 'ps_accounts.testimonials_url' => 'https://assets.prestashop3.com/dst/accounts/assets/testimonials.json', + + 'ps_accounts.log_level' => 'DEBUG', +]; diff --git a/config.prod.php b/config.prod.php new file mode 100644 index 000000000..3d12e757f --- /dev/null +++ b/config.prod.php @@ -0,0 +1,40 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +return [ + 'ps_accounts.environment' => 'production', + 'ps_accounts.accounts_api_url' => 'https://accounts-api.distribution.prestashop.net/', + 'ps_accounts.accounts_ui_url' => 'https://accounts.distribution.prestashop.net', + 'ps_accounts.sso_api_url' => 'https://auth.prestashop.com/api/v1/', + 'ps_accounts.sso_account_url' => 'https://auth.prestashop.com/login', + 'ps_accounts.sso_resend_verification_email_url' => 'https://auth.prestashop.com/account/send-verification-email', + 'ps_accounts.billing_api_url' => 'https://billing-api.distribution.prestashop.net/', + 'ps_accounts.indirect_channel_api_url' => 'https://indirect-channel-api.prestashop.net', + 'ps_accounts.sentry_credentials' => 'https://cd2a5f089edb6d6efe742c0cbe004106@o298402.ingest.us.sentry.io/5354585', + 'ps_accounts.segment_write_key' => 'pEJGnRxw47CU01efFjMyl1S7YcxshLxl', + 'ps_accounts.check_api_ssl_cert' => true, + 'ps_accounts.verify_account_tokens' => true, + 'ps_accounts.accounts_vue_cdn_url' => 'https://unpkg.com/prestashop_accounts_vue_components@3/dist/psaccountsVue.umd.min.js', + 'ps_accounts.accounts_cdn_url' => 'https://unpkg.com/prestashop_accounts_vue_components@5', + 'ps_accounts.svc_accounts_ui_url' => 'https://accounts.psessentials.net', + 'ps_accounts.oauth2_url' => 'https://oauth.prestashop.com', + + 'ps_accounts.testimonials_url' => 'https://assets.prestashop3.com/dst/accounts/assets/testimonials.json', +]; diff --git a/config/admin/services.yml b/config/admin/services.yml index 2cdfaacf2..0baad4766 100644 --- a/config/admin/services.yml +++ b/config/admin/services.yml @@ -1,2 +1 @@ -imports: - - { resource: ../config.yml } +services: diff --git a/config/command.yml b/config/command.yml deleted file mode 100644 index fb36f1aca..000000000 --- a/config/command.yml +++ /dev/null @@ -1,50 +0,0 @@ -services: - PrestaShop\Module\PsAccounts\Account\CommandHandler\LinkShopHandler: - class: PrestaShop\Module\PsAccounts\Account\CommandHandler\LinkShopHandler - public: true - arguments: - - '@PrestaShop\Module\PsAccounts\Account\LinkShop' - - PrestaShop\Module\PsAccounts\Account\CommandHandler\DeleteUserShopHandler: - class: PrestaShop\Module\PsAccounts\Account\CommandHandler\DeleteUserShopHandler - public: true - arguments: - - '@PrestaShop\Module\PsAccounts\Api\Client\AccountsClient' - - '@PrestaShop\Module\PsAccounts\Context\ShopContext' - - '@PrestaShop\Module\PsAccounts\Account\Session\Firebase\ShopSession' - - '@PrestaShop\Module\PsAccounts\Account\Session\Firebase\OwnerSession' - - PrestaShop\Module\PsAccounts\Account\CommandHandler\UnlinkShopHandler: - class: PrestaShop\Module\PsAccounts\Account\CommandHandler\UnlinkShopHandler - public: true - arguments: - - '@PrestaShop\Module\PsAccounts\Account\LinkShop' - - '@PrestaShop\Module\PsAccounts\Service\AnalyticsService' - - '@PrestaShop\Module\PsAccounts\Provider\ShopProvider' - - PrestaShop\Module\PsAccounts\Account\CommandHandler\UpdateUserShopHandler: - class: PrestaShop\Module\PsAccounts\Account\CommandHandler\UpdateUserShopHandler - public: true - arguments: - - '@PrestaShop\Module\PsAccounts\Api\Client\AccountsClient' - - '@PrestaShop\Module\PsAccounts\Context\ShopContext' - - '@PrestaShop\Module\PsAccounts\Account\Session\Firebase\ShopSession' - - '@PrestaShop\Module\PsAccounts\Account\Session\Firebase\OwnerSession' - - PrestaShop\Module\PsAccounts\Account\CommandHandler\UpgradeModuleHandler: - class: PrestaShop\Module\PsAccounts\Account\CommandHandler\UpgradeModuleHandler - public: true - arguments: - - '@PrestaShop\Module\PsAccounts\Api\Client\AccountsClient' - - '@PrestaShop\Module\PsAccounts\Account\LinkShop' - - '@PrestaShop\Module\PsAccounts\Account\Session\Firebase\ShopSession' - - '@PrestaShop\Module\PsAccounts\Context\ShopContext' - - '@PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository' - - '@PrestaShop\Module\PsAccounts\Cqrs\CommandBus' - - PrestaShop\Module\PsAccounts\Account\CommandHandler\UpgradeModuleMultiHandler: - class: PrestaShop\Module\PsAccounts\Account\CommandHandler\UpgradeModuleMultiHandler - public: true - arguments: - - '@PrestaShop\Module\PsAccounts\Cqrs\CommandBus' - - '@PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository' diff --git a/config/common.yml b/config/common.yml deleted file mode 100644 index d682e8ce2..000000000 --- a/config/common.yml +++ /dev/null @@ -1,221 +0,0 @@ -imports: - - { resource: command.yml } - -services: - ps_accounts.module: - class: Ps_accounts - public: true - factory: ['Module', 'getInstanceByName'] - arguments: - - 'ps_accounts' - - ps_accounts.context: - class: Context - public: true - factory: [ 'Context', 'getContext' ] - - ps_accounts.logger: - class: PrestaShop\Module\PsAccounts\Vendor\Monolog\Logger - public: true - factory: [ 'PrestaShop\Module\PsAccounts\Log\Logger', 'create' ] - arguments: - - '%ps_accounts.log_level%' - - PrestaShop\Module\PsAccounts\Provider\OAuth2\ShopProvider: - class: PrestaShop\Module\PsAccounts\Provider\OAuth2\ShopProvider - public: true - factory: [ 'PrestaShop\Module\PsAccounts\Provider\OAuth2\ShopProvider', 'create' ] - - PrestaShop\Module\PsAccounts\Provider\OAuth2\PrestaShopSession: - class: PrestaShop\Module\PsAccounts\Provider\OAuth2\PrestaShopSession - public: true - factory: [ 'PrestaShop\Module\PsAccounts\Factory\PrestaShopSessionFactory', 'create' ] - - PrestaShop\Module\PsAccounts\Provider\OAuth2\Oauth2Client: - class: PrestaShop\Module\PsAccounts\Provider\OAuth2\Oauth2Client - public: true - arguments: - - '@PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository' - - PrestaShop\Module\PsAccounts\Context\ShopContext: - class: PrestaShop\Module\PsAccounts\Context\ShopContext - public: true - arguments: - - '@PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository' - - '@ps_accounts.context' - - PrestaShop\Module\PsAccounts\Adapter\Configuration: - class: PrestaShop\Module\PsAccounts\Adapter\Configuration - public: true - arguments: - - '@ps_accounts.context' - - PrestaShop\Module\PsAccounts\Adapter\Link: - class: PrestaShop\Module\PsAccounts\Adapter\Link - public: true - arguments: - - '@PrestaShop\Module\PsAccounts\Context\ShopContext' - - ##################### - # installer - - PrestaShop\Module\PsAccounts\Installer\Installer: - class: PrestaShop\Module\PsAccounts\Installer\Installer - public: true - arguments: - - '@PrestaShop\Module\PsAccounts\Context\ShopContext' - - '@PrestaShop\Module\PsAccounts\Adapter\Link' - - ##################### - # services - - PrestaShop\Module\PsAccounts\Service\PsAccountsService: - class: PrestaShop\Module\PsAccounts\Service\PsAccountsService - public: true - arguments: - - '@ps_accounts.module' - - PrestaShop\Module\PsAccounts\Account\LinkShop: - class: PrestaShop\Module\PsAccounts\Account\LinkShop - public: true - arguments: - - '@PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository' - - PrestaShop\Module\PsAccounts\Service\PsBillingService: - class: PrestaShop\Module\PsAccounts\Service\PsBillingService - public: true - arguments: - - '@PrestaShop\Module\PsAccounts\Api\Client\ServicesBillingClient' - - '@PrestaShop\Module\PsAccounts\Repository\ShopTokenRepository' - - '@PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository' - - PrestaShop\Module\PsAccounts\Service\AnalyticsService: - class: PrestaShop\Module\PsAccounts\Service\AnalyticsService - public: true - arguments: - - '%ps_accounts.segment_write_key%' - - '@ps_accounts.logger' - - ##################### - # providers - - PrestaShop\Module\PsAccounts\Provider\ShopProvider: - class: PrestaShop\Module\PsAccounts\Provider\ShopProvider - public: true - arguments: - - '@PrestaShop\Module\PsAccounts\Context\ShopContext' - - '@PrestaShop\Module\PsAccounts\Adapter\Link' - - PrestaShop\Module\PsAccounts\Provider\RsaKeysProvider: - class: PrestaShop\Module\PsAccounts\Provider\RsaKeysProvider - public: true - arguments: - - '@PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository' - - PrestaShop\Module\PsAccounts\Factory\CircuitBreakerFactory: - class: PrestaShop\Module\PsAccounts\Factory\CircuitBreakerFactory - public: true - arguments: - - '@PrestaShop\Module\PsAccounts\Adapter\Configuration' - - ##################### - # handlers - - PrestaShop\Module\PsAccounts\Service\SentryService: - class: PrestaShop\Module\PsAccounts\Service\SentryService - public: true - arguments: - - '%ps_accounts.sentry_credentials%' - - '%ps_accounts.environment%' - - '@PrestaShop\Module\PsAccounts\Account\LinkShop' - - '@ps_accounts.context' - - ############### - # api clients - - PrestaShop\Module\PsAccounts\Api\Client\AccountsClient: - class: PrestaShop\Module\PsAccounts\Api\Client\AccountsClient - public: true - arguments: - - '%ps_accounts.accounts_api_url%' - - null - - 10 - - PrestaShop\Module\PsAccounts\Api\Client\ServicesBillingClient: - class: PrestaShop\Module\PsAccounts\Api\Client\ServicesBillingClient - public: true - arguments: - - '%ps_accounts.billing_api_url%' - - '@PrestaShop\Module\PsAccounts\Service\PsAccountsService' - - '@PrestaShop\Module\PsAccounts\Provider\ShopProvider' - - ##################### - # repositories - - PrestaShop\Module\PsAccounts\Account\Session\ShopSession: - class: PrestaShop\Module\PsAccounts\Account\Session\ShopSession - public: true - arguments: - - '@PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository' - - '@PrestaShop\Module\PsAccounts\Provider\OAuth2\ShopProvider' - - '@PrestaShop\Module\PsAccounts\Account\LinkShop' - - '@PrestaShop\Module\PsAccounts\Cqrs\CommandBus' - - PrestaShop\Module\PsAccounts\Account\Session\Firebase\ShopSession: - class: PrestaShop\Module\PsAccounts\Account\Session\Firebase\ShopSession - public: true - arguments: - - '@PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository' - - '@PrestaShop\Module\PsAccounts\Account\Session\ShopSession' - - PrestaShop\Module\PsAccounts\Account\Session\Firebase\OwnerSession: - class: PrestaShop\Module\PsAccounts\Account\Session\Firebase\OwnerSession - public: true - arguments: - - '@PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository' - - '@PrestaShop\Module\PsAccounts\Account\Session\ShopSession' - - PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository: - class: PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository - public: true - arguments: - - '@PrestaShop\Module\PsAccounts\Adapter\Configuration' - - PrestaShop\Module\PsAccounts\Repository\ShopTokenRepository: - class: PrestaShop\Module\PsAccounts\Repository\ShopTokenRepository - public: true - arguments: - - '@PrestaShop\Module\PsAccounts\Account\Session\Firebase\ShopSession' - - PrestaShop\Module\PsAccounts\Repository\UserTokenRepository: - class: PrestaShop\Module\PsAccounts\Repository\UserTokenRepository - public: true - arguments: - - '@PrestaShop\Module\PsAccounts\Account\Session\Firebase\OwnerSession' - - ##################### - # presenters - - PrestaShop\Module\PsAccounts\Presenter\PsAccountsPresenter: - class: PrestaShop\Module\PsAccounts\Presenter\PsAccountsPresenter - public: true - arguments: - - '@ps_accounts.module' - - ##################### - # CQRS - - PrestaShop\Module\PsAccounts\Cqrs\CommandBus: - class: PrestaShop\Module\PsAccounts\Cqrs\CommandBus - public: true - arguments: - - '@ps_accounts.module' - - ##################### - # Middleware - - PrestaShop\Module\PsAccounts\Middleware\Oauth2Middleware: - class: PrestaShop\Module\PsAccounts\Middleware\Oauth2Middleware - public: true - arguments: - - '@ps_accounts.module' diff --git a/config/config.yml.dist b/config/config.yml.dist deleted file mode 100644 index 5ec883625..000000000 --- a/config/config.yml.dist +++ /dev/null @@ -1,38 +0,0 @@ -imports: - - { resource: common.yml } - -parameters: - # In case you need to override with environment variables, you can follow this example : - # env(PS_ACCOUNTS_SENTRY_CREDENTIALS): 'https://4c7f6c8dd5aa405b8401a35f5cf26ada@o298402.ingest.sentry.io/5354585' - # sentry.credentials: '%env(string:PS_ACCOUNTS_SENTRY_CREDENTIALS)%' - # - # In order to manage multiple config files you can use PS_ACCOUNTS_ENV=[myenv] environment variable - # to load a specific services_[myenv].yml - - ps_accounts.accounts_api_url: 'https://accounts-api.prestashop.localhost/' - ps_accounts.accounts_ui_url: 'https://accounts.prestashop.localhost' - ps_accounts.sso_api_url: 'https://auth-preprod.prestashop.com/api/v1/' - ps_accounts.sso_account_url: 'https://authv2-preprod.prestashop.com/login' - ps_accounts.sso_resend_verification_email_url: 'https://auth-preprod.prestashop.com/account/send-verification-email' - ps_accounts.billing_api_url: 'https://billing-api.psessentials-integration.net' - ps_accounts.sentry_credentials: 'https://4c7f6c8dd5aa405b8401a35f5cf26ada@o298402.ingest.sentry.io/5354585' - ps_accounts.segment_write_key: 'UITzSdsFTgYsXaiJG09hsCiupUPwgJQB' - ps_accounts.check_api_ssl_cert: false - ps_accounts.verify_account_tokens: false - ps_accounts.accounts_vue_cdn_url: 'https://unpkg.com/prestashop_accounts_vue_components@3/dist/psaccountsVue.umd.min.js' - ps_accounts.accounts_cdn_url: 'https://unpkg.com/prestashop_accounts_vue_components@4/dist/psaccountsVue.umd.min.js' - ps_accounts.environment: 'development' - - # a page to display "Update Your Module" message - ps_accounts.svc_accounts_ui_url: 'https://accounts.psessentials-integration.net' - - # OAuth2 configuration url - ps_accounts.oauth2_url: 'https://oauth.prestashop.localhost' - - # Login page testimonials url - ps_accounts.testimonials_url: 'https://assets.prestashop3.com/dst/accounts/assets/testimonials.json' - - # optional log level (defaults to ERROR) - #ps_accounts.log_level: !php/const PrestaShop\Module\PsAccounts\Log\Logger::ERROR - ps_accounts.log_level: ERROR - diff --git a/config/front/services.yml b/config/front/services.yml index 2cdfaacf2..0baad4766 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -1,2 +1 @@ -imports: - - { resource: ../config.yml } +services: diff --git a/doc/upgrade-strategy.md b/doc/upgrade-strategy.md new file mode 100644 index 000000000..5ae05f0ec --- /dev/null +++ b/doc/upgrade-strategy.md @@ -0,0 +1,31 @@ +# Upgrade strategy + +## Hook (current solution) +* We must improve stability and avoid sending events if we detect an SQL error +* Maintaining upgrade status of the module is a core responsibility +* We take a risk every time we does an upgrade (crash, spamming shops ....) +* Heavy to use a hook triggered every time we display an admin page +* Having a look at the mixpanel we can see we have a regular number of shops spamming with disconnection events + +## Upgrade script with Curl & SQL +* Fastidious & we must duplicate rw code into every upgrade script + +## Autoload Hack +* positive benefits / risk balance +* seemless upgrade +* limited risk (only upgrade phase can be affected) +* NOT WORKING on PS1.7 (not reaching upgrade script) + + +# Dependencies with the core & between modules +## Dependencies collision +### fix: Scoping +# Dependencies between modules (sharing functionalities) +## fix: MBO +# Upgrade issues +## early hooks +### fix: stop using `actionDispatcherBefore` like hooks +## not up-to-date autoload +### fix: enforce autoload script + + diff --git a/ps_accounts.php b/ps_accounts.php index bebcc34e7..50c8716fa 100644 --- a/ps_accounts.php +++ b/ps_accounts.php @@ -102,21 +102,21 @@ class Ps_accounts extends Module 'displayDashboardTop', // toggle single/multi-shop -// 'actionObjectShopAddAfter', -// 'actionObjectShopDeleteAfter', + //'actionObjectShopAddAfter', + //'actionObjectShopDeleteAfter', // Login/Logout OAuth // PS 1.6 - 1.7 'displayBackOfficeHeader', 'actionAdminLoginControllerSetMedia', // PS >= 8 -// 'actionAdminControllerInitBefore', + //'actionAdminControllerInitBefore', ]; /** - * @var \PrestaShop\Module\PsAccounts\DependencyInjection\ServiceContainer + * @var \PrestaShop\Module\PsAccounts\ServiceContainer\PsAccountsServiceContainer */ - private $serviceContainer; + private $moduleContainer; /** * Ps_accounts constructor. @@ -191,8 +191,6 @@ public function install() $this->onModuleReset(); - $this->getLogger()->info('Install - Loading ' . $this->name . ' Env : [' . $this->getModuleEnv() . ']'); - return $status; } @@ -218,6 +216,7 @@ public function uninstall() */ public function getCoreServiceContainer() { + /* @phpstan-ignore-next-line */ if (method_exists($this, 'getContainer')) { return $this->getContainer(); } @@ -230,22 +229,19 @@ public function getCoreServiceContainer() } /** - * @return \PrestaShop\Module\PsAccounts\DependencyInjection\ServiceContainer + * @return \PrestaShop\Module\PsAccounts\ServiceContainer\PsAccountsServiceContainer * * @throws Exception */ public function getServiceContainer() { - if (null === $this->serviceContainer) { - // append version number to force cache generation (1.6 Core won't clear it) - $this->serviceContainer = new \PrestaShop\Module\PsAccounts\DependencyInjection\ServiceContainer( - $this->name . str_replace(['.', '-', '+'], '', $this->version), - $this->getLocalPath(), - $this->getModuleEnv() + if (null === $this->moduleContainer) { + $this->moduleContainer = \PrestaShop\Module\PsAccounts\ServiceContainer\PsAccountsServiceContainer::createInstance( + __DIR__ . '/config.php' ); } - return $this->serviceContainer; + return $this->moduleContainer; } /** @@ -265,7 +261,7 @@ public function getService($serviceName) */ public function getParameter($name) { - return $this->getServiceContainer()->getContainer()->getParameter($name); + return $this->getServiceContainer()->getParameter($name); } /** @@ -275,7 +271,7 @@ public function getParameter($name) */ public function hasParameter($name) { - return $this->getServiceContainer()->getContainer()->hasParameter($name); + return $this->getServiceContainer()->hasParameter($name); } /** @@ -336,24 +332,6 @@ public function addCustomHooks($customHooks) return $ret; } - /** - * @return string - */ - public function getModuleEnvVar() - { - return strtoupper((string) $this->name) . '_ENV'; - } - - /** - * @param string $default - * - * @return string - */ - public function getModuleEnv($default = null) - { - return getenv($this->getModuleEnvVar()) ?: $default ?: self::DEFAULT_ENV; - } - /** * Render the configuration form. * diff --git a/scoper.inc.php b/scoper.inc.php index d15fa7b28..ef8b1ed27 100644 --- a/scoper.inc.php +++ b/scoper.inc.php @@ -112,13 +112,13 @@ static function ($filePath, $prefix, $contents) { $contents ); } - if ($filePath === __DIR__ . '/vendor/symfony/dependency-injection/Compiler/PassConfig.php') { - return str_replace( - "'PrestaShop\\\\Module\\\\PsAccounts\\\\Vendor\\\\array_merge'", - "'\\array_merge'", - $contents - ); - } +// if ($filePath === __DIR__ . '/vendor/symfony/dependency-injection/Compiler/PassConfig.php') { +// return str_replace( +// "'PrestaShop\\\\Module\\\\PsAccounts\\\\Vendor\\\\array_merge'", +// "'\\array_merge'", +// $contents +// ); +// } // if ($filePath === __DIR__ . '/vendor/friendsofphp/php-cs-fixer/src/FixerFactory.php') { // // $fixerClass = 'PhpCsFixer\\Fixer\\' . ($relativeNamespace ? $relativeNamespace . '\\' : '') . $file->getBasename('.php'); // return preg_replace( diff --git a/scripts/bundle-module.sh b/scripts/bundle-module.sh index 12a904187..b5d005187 100755 --- a/scripts/bundle-module.sh +++ b/scripts/bundle-module.sh @@ -30,10 +30,10 @@ cd $dist || exit; # switch request configuration env if [ "$environment" ]; then - configFileEnv="./${module}/config/config.yml.${environment}" + configFileEnv="./${module}/config.${environment}.php" if [ -f "$configFileEnv" ]; then echo "using provided environment [${environment}]" - cp "$configFileEnv" "./${module}/config/config.yml" + cp "$configFileEnv" "./${module}/config.php" else echo "file not found [${configFileEnv}]" fi diff --git a/src/Account/Exception/InconsistentAssociationStateException.php b/src/Account/Exception/InconsistentAssociationStateException.php index 2e6d73e5f..0b8380fa0 100644 --- a/src/Account/Exception/InconsistentAssociationStateException.php +++ b/src/Account/Exception/InconsistentAssociationStateException.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsAccounts\Account\Exception; diff --git a/src/Adapter/Link.php b/src/Adapter/Link.php index 89f516f10..0940d66fb 100644 --- a/src/Adapter/Link.php +++ b/src/Adapter/Link.php @@ -59,12 +59,11 @@ public function __construct( * @param bool $withToken include or not the token in the url * @param array $sfRouteParams * @param array $params + * @param bool $absolute require an absolute uri * * @return string - * - * @throws \PrestaShopException */ - public function getAdminLink($controller, $withToken = true, $sfRouteParams = [], $params = []) + public function getAdminLink($controller, $withToken = true, $sfRouteParams = [], $params = [], $absolute = false) { // Cannot generate admin link from front if (!defined('_PS_ADMIN_DIR_')) { @@ -72,14 +71,41 @@ public function getAdminLink($controller, $withToken = true, $sfRouteParams = [] } if ($this->shopContext->isShop17()) { - return $this->link->getAdminLink($controller, $withToken, $sfRouteParams, $params); + $uri = $this->rel2abs( + $this->link->getAdminLink($controller, $withToken, $sfRouteParams, $params), + $absolute + ); + } else { + $uri = $this->getAdminLink16($controller, $withToken, $params); + } + + if (!$withToken) { + // FIXME: getAdminLink still adds the token (sometimes) + $uri = preg_replace('/&_token=[^&]*/', '', $uri); } + + return $uri; + } + + /** + * @param string $controller + * @param bool $withToken + * @param array $params + * + * @return string + */ + public function getAdminLink16($controller, $withToken, array $params) + { $paramsAsString = ''; foreach ($params as $key => $value) { $paramsAsString .= "&$key=$value"; } - return \Tools::getShopDomainSsl(true) . __PS_BASE_URI__ . basename(_PS_ADMIN_DIR_) . '/' . $this->link->getAdminLink($controller, $withToken) . $paramsAsString; + return \Tools::getShopDomainSsl(true) . // scheme + domain + __PS_BASE_URI__ . // physical + virtual + basename(_PS_ADMIN_DIR_) . '/' . // admin path + $this->link->getAdminLink($controller, $withToken) . + $paramsAsString; } /** @@ -101,8 +127,6 @@ public function getLink() * @param array $params * * @return string - * - * @throws \PrestaShopException */ public function getAdminLinkWithCustomDomain($sslDomain, $domain, $controller, $withToken = true, $sfRouteParams = [], $params = []) { @@ -119,4 +143,19 @@ public function getAdminLinkWithCustomDomain($sslDomain, $domain, $controller, $ return $boBaseUrl; } + + /** + * @param string $url + * @param bool $absolute + * + * @return string + */ + protected function rel2abs($url, $absolute) + { + if ($absolute && !preg_match('/https?:\/\//', $url)) { + $url = \Tools::getShopDomainSsl(true) . $url; + } + + return $url; + } } diff --git a/src/Api/Controller/AbstractRestController.php b/src/Api/Controller/AbstractRestController.php index 38daee4e5..61a6d7253 100644 --- a/src/Api/Controller/AbstractRestController.php +++ b/src/Api/Controller/AbstractRestController.php @@ -286,9 +286,8 @@ protected function decodePayload($defaultShopId = null) $publicKey = $shopKeysService->getPublicKey(); if ( - null !== $publicKey && - false !== $publicKey && - '' !== $publicKey && + !empty($publicKey) && + is_string($publicKey) && true === $jwt->verify(new Sha256(), new Key((string) $publicKey)) ) { return $jwt->claims()->all(); diff --git a/src/DependencyInjection/ContainerProvider.php b/src/DependencyInjection/ContainerProvider.php deleted file mode 100644 index e67a2369c..000000000 --- a/src/DependencyInjection/ContainerProvider.php +++ /dev/null @@ -1,119 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsAccounts\DependencyInjection; - -use PrestaShop\Module\PsAccounts\Vendor\PrestaShop\ModuleLibCacheDirectoryProvider\Cache\CacheDirectoryProvider; -use PrestaShop\Module\PsAccounts\Vendor\Symfony\Component\DependencyInjection\ContainerBuilder; -use PrestaShop\Module\PsAccounts\Vendor\Symfony\Component\DependencyInjection\ContainerInterface; -use PrestaShop\Module\PsAccounts\Vendor\Symfony\Component\DependencyInjection\Dumper\PhpDumper; -use PrestaShop\Module\PsAccounts\Vendor\Symfony\Component\DependencyInjection\Loader\YamlFileLoader; -use Symfony\Component\Config\ConfigCache; -use Symfony\Component\Config\FileLocator; - -class ContainerProvider -{ - /** - * @var string Module Name - */ - private $moduleName; - - /** - * @var string Module Local Path - */ - private $moduleLocalPath; - - /** - * @var string - */ - private $moduleEnv; - - /** - * @var CacheDirectoryProvider - */ - private $cacheDirectory; - - /** - * @param string $moduleName - * @param string $moduleLocalPath - * @param string $moduleEnv - * @param CacheDirectoryProvider $cacheDirectory - */ - public function __construct( - $moduleName, - $moduleLocalPath, - $moduleEnv, - CacheDirectoryProvider $cacheDirectory - ) { - $this->moduleName = $moduleName; - $this->moduleLocalPath = $moduleLocalPath; - $this->moduleEnv = $moduleEnv; - $this->cacheDirectory = $cacheDirectory; - } - - /** - * @param string $containerName - * - * @return ContainerInterface - * - * @throws \Exception - */ - public function get($containerName) - { - $containerClassName = ucfirst($this->moduleName) - . ucfirst($containerName) - . 'Container' - ; - $containerFilePath = $this->cacheDirectory->getPath() . '/' . $containerClassName . '.php'; - $containerConfigCache = new ConfigCache($containerFilePath, _PS_MODE_DEV_); - - if ($containerConfigCache->isFresh()) { - require_once $containerFilePath; - - /** @var ContainerInterface $instance */ - $instance = new $containerClassName(); - - return $instance; - } - - $containerBuilder = new ContainerBuilder(); - $containerBuilder->set( - $this->moduleName . '.cache.directory', - $this->cacheDirectory - ); - $moduleConfigPath = $this->moduleLocalPath - . 'config/' - . $containerName - ; - - $loader = new YamlFileLoader($containerBuilder, new FileLocator($moduleConfigPath)); - - $loader->load('services' . ($this->moduleEnv ? '_' . $this->moduleEnv : '') . '.yml'); - - $containerBuilder->compile(); - $dumper = new PhpDumper($containerBuilder); - $containerConfigCache->write( - $dumper->dump(['class' => $containerClassName]), - $containerBuilder->getResources() - ); - - return $containerBuilder; - } -} diff --git a/src/DependencyInjection/ServiceContainer.php b/src/DependencyInjection/ServiceContainer.php deleted file mode 100644 index 91ce3c817..000000000 --- a/src/DependencyInjection/ServiceContainer.php +++ /dev/null @@ -1,108 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace PrestaShop\Module\PsAccounts\DependencyInjection; - -use PrestaShop\Module\PsAccounts\Vendor\PrestaShop\ModuleLibCacheDirectoryProvider\Cache\CacheDirectoryProvider; -use PrestaShop\Module\PsAccounts\Vendor\Symfony\Component\DependencyInjection\ContainerInterface; - -class ServiceContainer -{ - /** - * @var string Module Name - */ - private $moduleName; - - /** - * @var string Module Local Path - */ - private $moduleLocalPath; - - /** - * @var string - */ - private $moduleEnv; - - /** - * @var ContainerInterface - */ - private $container; - - /** - * @param string $moduleName - * @param string $moduleLocalPath - * @param string $moduleEnv - * - * @throws \Exception - */ - public function __construct($moduleName, $moduleLocalPath, $moduleEnv) - { - $this->moduleName = $moduleName; - $this->moduleLocalPath = $moduleLocalPath; - $this->moduleEnv = $moduleEnv; - - $this->initContainer(); - } - - /** - * @param string $serviceName - * - * @return object|null - * - * @throws \Exception - */ - public function getService($serviceName) - { - return $this->getContainer()->get($serviceName); - } - - /** - * @return ContainerInterface - * - * @throws \Exception - */ - public function getContainer() - { - if (null === $this->container) { - $this->initContainer(); - } - - return $this->container; - } - - /** - * Instantiate a new ContainerProvider - * - * @return void - * - * @throws \Exception - */ - private function initContainer() - { - $cacheDirectory = new CacheDirectoryProvider( - _PS_VERSION_, - _PS_ROOT_DIR_, - _PS_MODE_DEV_ - ); - $containerProvider = new ContainerProvider($this->moduleName, $this->moduleLocalPath, $this->moduleEnv, $cacheDirectory); - - $this->container = $containerProvider->get(defined('_PS_ADMIN_DIR_') || defined('PS_INSTALLATION_IN_PROGRESS') ? 'admin' : 'front'); - } -} diff --git a/src/Polyfill/Traits/AdminController/IsAnonymousAllowed.php b/src/Polyfill/Traits/AdminController/IsAnonymousAllowed.php index d1bc4962f..f01e49fe1 100644 --- a/src/Polyfill/Traits/AdminController/IsAnonymousAllowed.php +++ b/src/Polyfill/Traits/AdminController/IsAnonymousAllowed.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsAccounts\Polyfill\Traits\AdminController; diff --git a/src/Polyfill/Traits/Controller/AjaxRender.php b/src/Polyfill/Traits/Controller/AjaxRender.php index 72fee5b2b..0c43a9973 100644 --- a/src/Polyfill/Traits/Controller/AjaxRender.php +++ b/src/Polyfill/Traits/Controller/AjaxRender.php @@ -1,4 +1,22 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace PrestaShop\Module\PsAccounts\Polyfill\Traits\Controller; @@ -19,6 +37,7 @@ protected function ajaxRender($value = null, $controller = null, $method = null) { $controllerBaseClass = \ControllerCore::class; if (is_a($this, $controllerBaseClass)) { + /* @phpstan-ignore-next-line */ if (method_exists($controllerBaseClass, 'ajaxRender')) { /* @phpstan-ignore-next-line */ parent::ajaxRender($value, $controller, $method); diff --git a/src/Provider/ShopProvider.php b/src/Provider/ShopProvider.php index ff9d8c41e..bb30bd4cc 100644 --- a/src/Provider/ShopProvider.php +++ b/src/Provider/ShopProvider.php @@ -102,7 +102,8 @@ public function formatShopData(array $shopData, $psxName = '', $refreshTokens = 'module_name' => $psxName, 'configure' => $psxName, 'setShopContext' => 's-' . $shopData['id_shop'], - ] + ], + true ), 'isLinkedV4' => null, 'unlinkedAuto' => !empty($linkShop->getUnlinkedOnError()), diff --git a/src/Repository/EmployeeAccountRepository.php b/src/Repository/EmployeeAccountRepository.php index 5d76e1616..9f19ad40e 100644 --- a/src/Repository/EmployeeAccountRepository.php +++ b/src/Repository/EmployeeAccountRepository.php @@ -38,6 +38,7 @@ public function __construct() { /** @var \Ps_accounts $module */ $module = \Module::getInstanceByName('ps_accounts'); + /* @phpstan-ignore-next-line */ if (method_exists($module, 'getContainer') && interface_exists('\Doctrine\ORM\EntityManagerInterface')) { /* @phpstan-ignore-next-line */ diff --git a/src/ServiceContainer/Provider/ApiClientProvider.php b/src/ServiceContainer/Provider/ApiClientProvider.php new file mode 100644 index 000000000..41a7291fa --- /dev/null +++ b/src/ServiceContainer/Provider/ApiClientProvider.php @@ -0,0 +1,54 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PsAccounts\ServiceContainer\Provider; + +use PrestaShop\Module\PsAccounts\Api\Client\AccountsClient; +use PrestaShop\Module\PsAccounts\Api\Client\ServicesBillingClient; +use PrestaShop\Module\PsAccounts\Provider\ShopProvider; +use PrestaShop\Module\PsAccounts\Service\PsAccountsService; +use PrestaShop\Module\PsAccounts\Vendor\PrestaShopCorp\LightweightContainer\ServiceContainer\Contract\IServiceProvider; +use PrestaShop\Module\PsAccounts\Vendor\PrestaShopCorp\LightweightContainer\ServiceContainer\ServiceContainer; + +class ApiClientProvider implements IServiceProvider +{ + /** + * @param ServiceContainer $container + * + * @return void + */ + public function provide(ServiceContainer $container) + { + $container->registerProvider(AccountsClient::class, static function () use ($container) { + return new AccountsClient( + $container->getParameter('ps_accounts.accounts_api_url'), + null, + 10 + ); + }); + $container->registerProvider(ServicesBillingClient::class, static function () use ($container) { + return new ServicesBillingClient( + $container->getParameter('ps_accounts.billing_api_url'), + $container->get(PsAccountsService::class), + $container->get(ShopProvider::class) + ); + }); + } +} diff --git a/src/ServiceContainer/Provider/CommandProvider.php b/src/ServiceContainer/Provider/CommandProvider.php new file mode 100644 index 000000000..dea8bf856 --- /dev/null +++ b/src/ServiceContainer/Provider/CommandProvider.php @@ -0,0 +1,90 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PsAccounts\ServiceContainer\Provider; + +use PrestaShop\Module\PsAccounts\Account\CommandHandler\DeleteUserShopHandler; +use PrestaShop\Module\PsAccounts\Account\CommandHandler\LinkShopHandler; +use PrestaShop\Module\PsAccounts\Account\CommandHandler\UnlinkShopHandler; +use PrestaShop\Module\PsAccounts\Account\CommandHandler\UpdateUserShopHandler; +use PrestaShop\Module\PsAccounts\Account\CommandHandler\UpgradeModuleHandler; +use PrestaShop\Module\PsAccounts\Account\CommandHandler\UpgradeModuleMultiHandler; +use PrestaShop\Module\PsAccounts\Account\LinkShop; +use PrestaShop\Module\PsAccounts\Account\Session\Firebase\OwnerSession; +use PrestaShop\Module\PsAccounts\Account\Session\Firebase\ShopSession; +use PrestaShop\Module\PsAccounts\Api\Client\AccountsClient; +use PrestaShop\Module\PsAccounts\Context\ShopContext; +use PrestaShop\Module\PsAccounts\Cqrs\CommandBus; +use PrestaShop\Module\PsAccounts\Provider\ShopProvider; +use PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository; +use PrestaShop\Module\PsAccounts\Service\AnalyticsService; +use PrestaShop\Module\PsAccounts\Vendor\PrestaShopCorp\LightweightContainer\ServiceContainer\Contract\IServiceProvider; +use PrestaShop\Module\PsAccounts\Vendor\PrestaShopCorp\LightweightContainer\ServiceContainer\ServiceContainer; + +class CommandProvider implements IServiceProvider +{ + public function provide(ServiceContainer $container) + { + $container->registerProvider(DeleteUserShopHandler::class, static function () use ($container) { + return new DeleteUserShopHandler( + $container->get(AccountsClient::class), + $container->get(ShopContext::class), + $container->get(ShopSession::class), + $container->get(OwnerSession::class) + ); + }); + $container->registerProvider(LinkShopHandler::class, static function () use ($container) { + return new LinkShopHandler( + $container->get(LinkShop::class) + ); + }); + $container->registerProvider(UnlinkShopHandler::class, static function () use ($container) { + return new UnlinkShopHandler( + $container->get(LinkShop::class), + $container->get(AnalyticsService::class), + $container->get(ShopProvider::class) + ); + }); + $container->registerProvider(UpdateUserShopHandler::class, static function () use ($container) { + return new UpdateUserShopHandler( + $container->get(AccountsClient::class), + $container->get(ShopContext::class), + $container->get(ShopSession::class), + $container->get(OwnerSession::class) + ); + }); + $container->registerProvider(UpgradeModuleHandler::class, static function () use ($container) { + return new UpgradeModuleHandler( + $container->get(AccountsClient::class), + $container->get(LinkShop::class), + $container->get(ShopSession::class), + $container->get(ShopContext::class), + $container->get(ConfigurationRepository::class), + $container->get(CommandBus::class) + ); + }); + $container->registerProvider(UpgradeModuleMultiHandler::class, static function () use ($container) { + return new UpgradeModuleMultiHandler( + $container->get(CommandBus::class), + $container->get(ConfigurationRepository::class) + ); + }); + } +} diff --git a/src/ServiceContainer/Provider/DefaultProvider.php b/src/ServiceContainer/Provider/DefaultProvider.php new file mode 100644 index 000000000..b9bb30f0d --- /dev/null +++ b/src/ServiceContainer/Provider/DefaultProvider.php @@ -0,0 +1,149 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PsAccounts\ServiceContainer\Provider; + +use PrestaShop\Module\PsAccounts\Account\LinkShop; +use PrestaShop\Module\PsAccounts\Adapter; +use PrestaShop\Module\PsAccounts\Adapter\Configuration; +use PrestaShop\Module\PsAccounts\Adapter\Link; +use PrestaShop\Module\PsAccounts\Api\Client\ServicesBillingClient; +use PrestaShop\Module\PsAccounts\Context\ShopContext; +use PrestaShop\Module\PsAccounts\Cqrs\CommandBus; +use PrestaShop\Module\PsAccounts\Factory\CircuitBreakerFactory; +use PrestaShop\Module\PsAccounts\Installer\Installer; +use PrestaShop\Module\PsAccounts\Presenter\PsAccountsPresenter; +use PrestaShop\Module\PsAccounts\Provider; +use PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository; +use PrestaShop\Module\PsAccounts\Repository\ShopTokenRepository; +use PrestaShop\Module\PsAccounts\Service\AnalyticsService; +use PrestaShop\Module\PsAccounts\Service\PsAccountsService; +use PrestaShop\Module\PsAccounts\Service\PsBillingService; +use PrestaShop\Module\PsAccounts\Service\SentryService; +use PrestaShop\Module\PsAccounts\Vendor\PrestaShopCorp\LightweightContainer\ServiceContainer\Contract\IServiceProvider; +use PrestaShop\Module\PsAccounts\Vendor\PrestaShopCorp\LightweightContainer\ServiceContainer\ServiceContainer; + +class DefaultProvider implements IServiceProvider +{ + /** + * @param ServiceContainer $container + * + * @return void + */ + public function provide(ServiceContainer $container) + { + $container->set('ps_accounts.logger', $container->getLogger()); + + $container->registerProvider('ps_accounts.context', static function () { + return \Context::getContext(); + }); + $container->registerProvider('ps_accounts.module', static function () { + return \Module::getInstanceByName('ps_accounts'); + }); + // Entities ? + $container->registerProvider(LinkShop::class, static function () use ($container) { + return new LinkShop( + $container->get(ConfigurationRepository::class) + ); + }); + // Adapter + $container->registerProvider(Adapter\Configuration::class, static function () use ($container) { + return new Adapter\Configuration( + $container->get('ps_accounts.context') + ); + }); + $container->registerProvider(Adapter\Link::class, static function () use ($container) { + return new Adapter\Link( + $container->get(ShopContext::class) + ); + }); + // Services + $container->registerProvider(AnalyticsService::class, static function () use ($container) { + return new AnalyticsService( + $container->getParameter('ps_accounts.segment_write_key'), + $container->get('ps_accounts.logger') + ); + }); + $container->registerProvider(PsAccountsService::class, static function () use ($container) { + return new PsAccountsService( + $container->get('ps_accounts.module') + ); + }); + $container->registerProvider(PsBillingService::class, static function () use ($container) { + return new PsBillingService( + $container->get(ServicesBillingClient::class), + $container->get(ShopTokenRepository::class), + $container->get(ConfigurationRepository::class) + ); + }); + $container->registerProvider(SentryService::class, static function () use ($container) { + return new SentryService( + $container->getParameter('ps_accounts.sentry_credentials'), + $container->getParameter('ps_accounts.environment'), + $container->get(LinkShop::class), + $container->get('ps_accounts.context') + ); + }); + // "Providers" + $container->registerProvider(Provider\RsaKeysProvider::class, static function () use ($container) { + return new Provider\RsaKeysProvider( + $container->get(ConfigurationRepository::class) + ); + }); + $container->registerProvider(Provider\ShopProvider::class, static function () use ($container) { + return new Provider\ShopProvider( + $container->get(ShopContext::class), + $container->get(Link::class) + ); + }); + // Context + $container->registerProvider(ShopContext::class, static function () use ($container) { + return new ShopContext( + $container->get(ConfigurationRepository::class), + $container->get('ps_accounts.context') + ); + }); + // CQRS + $container->registerProvider(CommandBus::class, static function () use ($container) { + return new CommandBus( + $container->get('ps_accounts.module') + ); + }); + // Factories + $container->registerProvider(CircuitBreakerFactory::class, static function () use ($container) { + return new CircuitBreakerFactory( + $container->get(Configuration::class) + ); + }); + // Installer + $container->registerProvider(Installer::class, static function () use ($container) { + return new Installer( + $container->get(ShopContext::class), + $container->get(Link::class) + ); + }); + // Presenter + $container->registerProvider(PsAccountsPresenter::class, static function () use ($container) { + return new PsAccountsPresenter( + $container->get('ps_accounts.module') + ); + }); + } +} diff --git a/src/ServiceContainer/Provider/OAuth2Provider.php b/src/ServiceContainer/Provider/OAuth2Provider.php new file mode 100644 index 000000000..62d9ab984 --- /dev/null +++ b/src/ServiceContainer/Provider/OAuth2Provider.php @@ -0,0 +1,58 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PsAccounts\ServiceContainer\Provider; + +use PrestaShop\Module\PsAccounts\Factory\PrestaShopSessionFactory; +use PrestaShop\Module\PsAccounts\Middleware\Oauth2Middleware; +use PrestaShop\Module\PsAccounts\Provider; +use PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository; +use PrestaShop\Module\PsAccounts\Vendor\PrestaShopCorp\LightweightContainer\ServiceContainer\Contract\IServiceProvider; +use PrestaShop\Module\PsAccounts\Vendor\PrestaShopCorp\LightweightContainer\ServiceContainer\ServiceContainer; + +class OAuth2Provider implements IServiceProvider +{ + /** + * @param ServiceContainer $container + * + * @return void + */ + public function provide(ServiceContainer $container) + { + // OAuth2 + $container->registerProvider(Provider\OAuth2\Oauth2Client::class, static function () use ($container) { + return new Provider\OAuth2\Oauth2Client( + $container->get(ConfigurationRepository::class) + ); + }); + $container->registerProvider(Provider\OAuth2\PrestaShopSession::class, static function () { + return PrestaShopSessionFactory::create(); + }); + $container->registerProvider(Provider\OAuth2\ShopProvider::class, static function () { + return Provider\OAuth2\ShopProvider::create(); + }); + // Middleware + $container->registerProvider(Oauth2Middleware::class, static function () use ($container) { + return new Oauth2Middleware( + $container->get('ps_accounts.module') + ); + }); + } +} diff --git a/src/ServiceContainer/Provider/RepositoryProvider.php b/src/ServiceContainer/Provider/RepositoryProvider.php new file mode 100644 index 000000000..5b84a4eed --- /dev/null +++ b/src/ServiceContainer/Provider/RepositoryProvider.php @@ -0,0 +1,58 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PsAccounts\ServiceContainer\Provider; + +use PrestaShop\Module\PsAccounts\Account\Session\Firebase; +use PrestaShop\Module\PsAccounts\Account\Session\Firebase\OwnerSession; +use PrestaShop\Module\PsAccounts\Adapter\Configuration; +use PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository; +use PrestaShop\Module\PsAccounts\Repository\ShopTokenRepository; +use PrestaShop\Module\PsAccounts\Repository\UserTokenRepository; +use PrestaShop\Module\PsAccounts\Vendor\PrestaShopCorp\LightweightContainer\ServiceContainer\Contract\IServiceProvider; +use PrestaShop\Module\PsAccounts\Vendor\PrestaShopCorp\LightweightContainer\ServiceContainer\ServiceContainer; + +class RepositoryProvider implements IServiceProvider +{ + /** + * @param ServiceContainer $container + * + * @return void + */ + public function provide(ServiceContainer $container) + { + // Repositories + $container->registerProvider(ConfigurationRepository::class, static function () use ($container) { + return new ConfigurationRepository( + $container->get(Configuration::class) + ); + }); + $container->registerProvider(ShopTokenRepository::class, static function () use ($container) { + return new ShopTokenRepository( + $container->get(Firebase\ShopSession::class) + ); + }); + $container->registerProvider(UserTokenRepository::class, static function () use ($container) { + return new UserTokenRepository( + $container->get(OwnerSession::class) + ); + }); + } +} diff --git a/src/ServiceContainer/Provider/SessionProvider.php b/src/ServiceContainer/Provider/SessionProvider.php new file mode 100644 index 000000000..30e7c14b0 --- /dev/null +++ b/src/ServiceContainer/Provider/SessionProvider.php @@ -0,0 +1,63 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PsAccounts\ServiceContainer\Provider; + +use PrestaShop\Module\PsAccounts\Account\LinkShop; +use PrestaShop\Module\PsAccounts\Account\Session\Firebase; +use PrestaShop\Module\PsAccounts\Account\Session\ShopSession; +use PrestaShop\Module\PsAccounts\Cqrs\CommandBus; +use PrestaShop\Module\PsAccounts\Provider\OAuth2\ShopProvider; +use PrestaShop\Module\PsAccounts\Repository\ConfigurationRepository; +use PrestaShop\Module\PsAccounts\Vendor\PrestaShopCorp\LightweightContainer\ServiceContainer\Contract\IServiceProvider; +use PrestaShop\Module\PsAccounts\Vendor\PrestaShopCorp\LightweightContainer\ServiceContainer\ServiceContainer; + +class SessionProvider implements IServiceProvider +{ + /** + * @param ServiceContainer $container + * + * @return void + */ + public function provide(ServiceContainer $container) + { + // Sessions + $container->registerProvider(ShopSession::class, static function () use ($container) { + return new ShopSession( + $container->get(ConfigurationRepository::class), + $container->get(ShopProvider::class), + $container->get(LinkShop::class), + $container->get(CommandBus::class) + ); + }); + $container->registerProvider(Firebase\OwnerSession::class, static function () use ($container) { + return new Firebase\OwnerSession( + $container->get(ConfigurationRepository::class), + $container->get(ShopSession::class) + ); + }); + $container->registerProvider(Firebase\ShopSession::class, static function () use ($container) { + return new Firebase\ShopSession( + $container->get(ConfigurationRepository::class), + $container->get(ShopSession::class) + ); + }); + } +} diff --git a/src/ServiceContainer/PsAccountsServiceContainer.php b/src/ServiceContainer/PsAccountsServiceContainer.php new file mode 100644 index 000000000..fa4351782 --- /dev/null +++ b/src/ServiceContainer/PsAccountsServiceContainer.php @@ -0,0 +1,62 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PsAccounts\ServiceContainer; + +use Monolog\Logger; +use PrestaShop\Module\PsAccounts\Log\Logger as LoggerFactory; +use PrestaShop\Module\PsAccounts\Vendor\PrestaShopCorp\LightweightContainer\ServiceContainer\ServiceContainer; + +class PsAccountsServiceContainer extends ServiceContainer +{ + /** + * @var Logger + */ + protected $logger; + + /** + * @var string[] + */ + protected $provides = [ + Provider\ApiClientProvider::class, + Provider\CommandProvider::class, + Provider\DefaultProvider::class, + Provider\OAuth2Provider::class, + Provider\RepositoryProvider::class, + Provider\SessionProvider::class, + ]; + + /** + * @return Logger + */ + public function getLogger() + { + if (null === $this->logger) { + $this->logger = LoggerFactory::create( + $this->getParameterWithDefault( + 'ps_accounts.log_level', + LoggerFactory::ERROR + ) + ); + } + + return $this->logger; + } +} diff --git a/tests/Feature/Account/CommandHandler/UpgradeModuleHandlerTest.php b/tests/Feature/Account/CommandHandler/UpgradeModuleHandlerTest.php index ee8571039..da7e8e164 100644 --- a/tests/Feature/Account/CommandHandler/UpgradeModuleHandlerTest.php +++ b/tests/Feature/Account/CommandHandler/UpgradeModuleHandlerTest.php @@ -127,6 +127,10 @@ protected function loginIntoBackoffice() { $jar = $this->cookieJar; + $resLoginPage = $this->displayLoginPage($jar); + + $this->module->getLogger()->info(print_r($resLoginPage->getBody(), true)); + $this->assertResponseOk( $this->displayLoginPage($jar) ); diff --git a/tests/composer.json b/tests/composer.json index 812428f23..3bcfc4b2c 100644 --- a/tests/composer.json +++ b/tests/composer.json @@ -22,7 +22,8 @@ "fzaninotto/faker": "dev-master", "phpunit/phpunit": "^9.6", "friendsofphp/php-cs-fixer": "^3.59", - "prestashop/php-dev-tools": "^5" + "phpstan/phpstan": "^2.0", + "prestashop/php-dev-tools": "^5.0" }, "scripts": { "phpunit": "docker exec -u www-data -ti phpunit-dev ./vendor/bin/phpunit --configuration './phpunit.xml' --test-suffix 'Test.php,.phpt'" diff --git a/tests/composer.lock b/tests/composer.lock index 3a31db02e..d3f9b9143 100644 --- a/tests/composer.lock +++ b/tests/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2e12f08dc6a25ddf37902901d739ec4b", + "content-hash": "a2dc26f57c10100faa415546bb1ec475", "packages": [], "packages-dev": [ { @@ -914,6 +914,64 @@ }, "time": "2022-02-21T01:04:05+00:00" }, + { + "name": "phpstan/phpstan", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "6c98c7600fc717b2c78c11ef60040d5b1e359c82" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/6c98c7600fc717b2c78c11ef60040d5b1e359c82", + "reference": "6c98c7600fc717b2c78c11ef60040d5b1e359c82", + "shasum": "" + }, + "require": { + "php": "^7.4|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + } + ], + "time": "2024-11-17T14:17:00+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "9.2.32", diff --git a/tests/phpstan/phpstan-PS-1.7.neon b/tests/phpstan/phpstan-PS-1.7.neon index 7ce546314..b73ea9e7b 100644 --- a/tests/phpstan/phpstan-PS-1.7.neon +++ b/tests/phpstan/phpstan-PS-1.7.neon @@ -1,8 +1,9 @@ includes: - %currentWorkingDirectory%/vendor/prestashop/php-dev-tools/phpstan/ps-module-extension.neon parameters: - checkMissingIterableValueType: false + #checkMissingIterableValueType: false reportUnmatchedIgnoredErrors: false + #treatPhpDocTypesAsCertain: false paths: - ../../src - ../../controllers @@ -39,5 +40,7 @@ parameters: - '#Call to method get\(\) on an unknown class PrestaShop\\PrestaShop\\Adapter\\SymfonyContainer.#' - '#Call to static method getInstance\(\) on an unknown class PrestaShop\\PrestaShop\\Adapter\\SymfonyContainer.#' - '#Call to an undefined method object::generate\(\).#' + - '#no value type specified in iterable type array#' + - '#has Exception in PHPDoc @throws tag but it.s not thrown#' level: 7 From db861b46dbbc6d6b446a3ce8a8959e4bfba74bfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Schoenenberger?= <54308193+hschoenenberger@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:27:51 +0100 Subject: [PATCH 2/2] [ACCOUNT-2760] refactor: refine scoping & fix some display hooks (#460) * refactor: refine scoping & fix some display hooks * fix: retrocompat service sharing * fix: admin ajax controller for 1.6 --- _dev/package.json | 2 +- composer.json | 6 +- composer.lock | 50 ++++++++-------- config.xml | 2 +- config/admin/services.yml | 4 +- config/common.yml | 35 ++++++++++++ config/front/services.yml | 3 +- .../admin/AdminAjaxPsAccountsController.php | 1 + .../admin/AdminOAuth2PsAccountsController.php | 2 +- ps_accounts.php | 46 ++------------- scoper.inc.php | 7 ++- src/Context/ShopContext.php | 2 - .../AccountLogin/AccountLoginException.php | 2 +- .../EmailNotVerifiedException.php | 2 +- .../EmployeeNotFoundException.php | 2 +- .../AccountLogin/Oauth2Exception.php | 2 +- src/Hook/DisplayAccountUpdateWarning.php | 41 +++++++------ src/Hook/DisplayDashboardTop.php | 57 ++++++++++++++----- src/Hook/Hook.php | 2 +- src/Log/Logger.php | 4 +- src/Presenter/DependenciesPresenter.php | 3 + src/Provider/OAuth2/PrestaShopLoginTrait.php | 2 +- src/Provider/OAuth2/PrestaShopSession.php | 2 +- src/Provider/OAuth2/ShopProvider.php | 2 +- src/Service/AnalyticsService.php | 2 +- ...eContainer.php => PsAccountsContainer.php} | 4 +- src/ServiceContainer/StaticProvider.php | 37 ++++++++++++ .../backoffice/delete_url_warning.twig | 9 --- .../backoffice/update_url_warning.twig | 9 --- 29 files changed, 202 insertions(+), 140 deletions(-) create mode 100644 config/common.yml rename src/ServiceContainer/{PsAccountsServiceContainer.php => PsAccountsContainer.php} (94%) create mode 100644 src/ServiceContainer/StaticProvider.php delete mode 100644 views/templates/backoffice/delete_url_warning.twig delete mode 100644 views/templates/backoffice/update_url_warning.twig diff --git a/_dev/package.json b/_dev/package.json index e982bf432..1434ea419 100644 --- a/_dev/package.json +++ b/_dev/package.json @@ -1,6 +1,6 @@ { "name": "ps_accounts", - "version": "7.0.8", + "version": "7.0.9", "private": true, "scripts": { "dev": "vite", diff --git a/composer.json b/composer.json index d6d43f0c5..f79cc7f0a 100644 --- a/composer.json +++ b/composer.json @@ -27,11 +27,13 @@ "PrestaShop\\Module\\PsAccounts\\Vendor\\GuzzleHttp\\Psr7\\": "vendor/guzzlehttp/psr7/src", "PrestaShop\\Module\\PsAccounts\\Vendor\\League\\OAuth2\\Client\\": "vendor/league/oauth2-client/src", "PrestaShop\\Module\\PsAccounts\\Vendor\\Lcobucci\\JWT\\": "vendor/lcobucci/jwt/src", + "PrestaShop\\Module\\PsAccounts\\Vendor\\Monolog\\": "vendor/monolog/monolog/src/Monolog", "PrestaShop\\Module\\PsAccounts\\Vendor\\phpseclib\\": "vendor/phpseclib/phpseclib/phpseclib", "PrestaShop\\Module\\PsAccounts\\Vendor\\Psr\\Http\\Message\\": "vendor/psr/http-message/src", "PrestaShop\\Module\\PsAccounts\\Vendor\\Psr\\Log\\": "vendor/psr/log/Psr/Log", "PrestaShop\\Module\\PsAccounts\\Vendor\\Ramsey\\Uuid\\": "vendor/ramsey/uuid/src", - "PrestaShop\\Module\\PsAccounts\\Vendor\\PrestaShopCorp\\LightweightContainer\\": "vendor/prestashopcorp/lightweight-container/src" + "PrestaShop\\Module\\PsAccounts\\Vendor\\PrestaShopCorp\\LightweightContainer\\": "vendor/prestashopcorp/lightweight-container/src", + "PrestaShop\\Module\\PsAccounts\\Vendor\\PrestaShop\\OAuth2\\Client\\": "vendor/prestashopcorp/oauth2-prestashop/src" }, "classmap": [ "ps_accounts.php", @@ -43,7 +45,7 @@ "phpseclib/phpseclib": "^2.0", "ext-json": "*", "lcobucci/jwt": "^3.3", - "monolog/monolog": "^1.25.3", + "monolog/monolog": "^1.27.1", "sentry/sentry": "^1.0", "segmentio/analytics-php": "^1.8", "ramsey/uuid": "^3.9", diff --git a/composer.lock b/composer.lock index adb21b00d..c69d46982 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e1e08bc9be7000c8d1553fbbafe15167", + "content-hash": "100f168b5e2fe820e472338caa90567b", "packages": [ { "name": "guzzlehttp/guzzle", @@ -708,12 +708,12 @@ "source": { "type": "git", "url": "https://github.com/PrestaShopCorp/lightweight-container.git", - "reference": "1f160049867672be909c653e9adcb818d4befd30" + "reference": "864578853c19d3c18728d5ccf3e4d2e98141a3de" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PrestaShopCorp/lightweight-container/zipball/1f160049867672be909c653e9adcb818d4befd30", - "reference": "1f160049867672be909c653e9adcb818d4befd30", + "url": "https://api.github.com/repos/PrestaShopCorp/lightweight-container/zipball/864578853c19d3c18728d5ccf3e4d2e98141a3de", + "reference": "864578853c19d3c18728d5ccf3e4d2e98141a3de", "shasum": "" }, "require": { @@ -737,7 +737,7 @@ "source": "https://github.com/PrestaShopCorp/lightweight-container/tree/main", "issues": "https://github.com/PrestaShopCorp/lightweight-container/issues" }, - "time": "2024-11-26T14:42:14+00:00" + "time": "2024-11-27T13:13:53+00:00" }, { "name": "prestashopcorp/oauth2-prestashop", @@ -1187,12 +1187,12 @@ }, "type": "library", "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + }, "branch-alias": { "dev-main": "1.19-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -1269,12 +1269,12 @@ }, "type": "library", "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + }, "branch-alias": { "dev-main": "1.19-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -1354,12 +1354,12 @@ }, "type": "library", "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + }, "branch-alias": { "dev-main": "1.19-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -1436,12 +1436,12 @@ }, "type": "library", "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + }, "branch-alias": { "dev-main": "1.19-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -1515,12 +1515,12 @@ }, "type": "library", "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + }, "branch-alias": { "dev-main": "1.19-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" } }, "autoload": { diff --git a/config.xml b/config.xml index 22bc190b7..2469e908f 100644 --- a/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ ps_accounts - + diff --git a/config/admin/services.yml b/config/admin/services.yml index 0baad4766..502eeeab5 100644 --- a/config/admin/services.yml +++ b/config/admin/services.yml @@ -1 +1,3 @@ -services: +imports: + - { resource: ../common.yml } + diff --git a/config/common.yml b/config/common.yml new file mode 100644 index 000000000..ac6af0ea4 --- /dev/null +++ b/config/common.yml @@ -0,0 +1,35 @@ +services: + ########################## + # Shared Services : + # Those services might be accessed directly from the core container + # by some modules. + # Doing so we maintain compatibility & ensure the same instance is provided. + + PrestaShop\Module\PsAccounts\Service\PsAccountsService: + class: PrestaShop\Module\PsAccounts\Service\PsAccountsService + public: true + factory: ['PrestaShop\Module\PsAccounts\ServiceContainer\StaticProvider', 'provide'] + arguments: + - 'PrestaShop\Module\PsAccounts\Service\PsAccountsService' + + PrestaShop\Module\PsAccounts\Service\PsBillingService: + class: PrestaShop\Module\PsAccounts\Service\PsBillingService + public: true + factory: [ 'PrestaShop\Module\PsAccounts\ServiceContainer\StaticProvider', 'provide' ] + arguments: + - 'PrestaShop\Module\PsAccounts\Service\PsBillingService' + + PrestaShop\Module\PsAccounts\Repository\UserTokenRepository: + class: PrestaShop\Module\PsAccounts\Repository\UserTokenRepository + public: true + factory: ['PrestaShop\Module\PsAccounts\ServiceContainer\StaticProvider', 'provide'] + arguments: + - 'PrestaShop\Module\PsAccounts\Repository\UserTokenRepository' + + PrestaShop\Module\PsAccounts\Presenter\PsAccountsPresenter: + class: PrestaShop\Module\PsAccounts\Presenter\PsAccountsPresenter + public: true + factory: ['PrestaShop\Module\PsAccounts\ServiceContainer\StaticProvider', 'provide'] + arguments: + - 'PrestaShop\Module\PsAccounts\Presenter\PsAccountsPresenter' + diff --git a/config/front/services.yml b/config/front/services.yml index 0baad4766..6e16e432b 100644 --- a/config/front/services.yml +++ b/config/front/services.yml @@ -1 +1,2 @@ -services: +imports: + - { resource: ../common.yml } diff --git a/controllers/admin/AdminAjaxPsAccountsController.php b/controllers/admin/AdminAjaxPsAccountsController.php index 4063b0b64..238c8edf3 100644 --- a/controllers/admin/AdminAjaxPsAccountsController.php +++ b/controllers/admin/AdminAjaxPsAccountsController.php @@ -17,6 +17,7 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +require_once __DIR__ . '/../../src/Polyfill/Traits/Controller/AjaxRender.php'; use PrestaShop\Module\PsAccounts\Account\Command\DeleteUserShopCommand; use PrestaShop\Module\PsAccounts\Account\Command\UnlinkShopCommand; diff --git a/controllers/admin/AdminOAuth2PsAccountsController.php b/controllers/admin/AdminOAuth2PsAccountsController.php index 5dbda0e72..bf103c530 100644 --- a/controllers/admin/AdminOAuth2PsAccountsController.php +++ b/controllers/admin/AdminOAuth2PsAccountsController.php @@ -29,7 +29,7 @@ use PrestaShop\Module\PsAccounts\Repository\EmployeeAccountRepository; use PrestaShop\Module\PsAccounts\Service\AnalyticsService; use PrestaShop\Module\PsAccounts\Service\PsAccountsService; -use PrestaShop\OAuth2\Client\Provider\PrestaShopUser; +use PrestaShop\Module\PsAccounts\Vendor\PrestaShop\OAuth2\Client\Provider\PrestaShopUser; use Symfony\Component\HttpFoundation\Session\SessionInterface; /** diff --git a/ps_accounts.php b/ps_accounts.php index 50c8716fa..830f87432 100644 --- a/ps_accounts.php +++ b/ps_accounts.php @@ -34,7 +34,7 @@ class Ps_accounts extends Module // Needed in order to retrieve the module version easier (in api call headers) than instanciate // the module each time to get the version - const VERSION = '7.0.8'; + const VERSION = '7.0.9'; /** * Admin tabs @@ -114,7 +114,7 @@ class Ps_accounts extends Module ]; /** - * @var \PrestaShop\Module\PsAccounts\ServiceContainer\PsAccountsServiceContainer + * @var \PrestaShop\Module\PsAccounts\ServiceContainer\PsAccountsContainer */ private $moduleContainer; @@ -131,7 +131,7 @@ public function __construct() // We cannot use the const VERSION because the const is not computed by addons marketplace // when the zip is uploaded - $this->version = '7.0.8'; + $this->version = '7.0.9'; $this->module_key = 'abf2cd758b4d629b2944d3922ef9db73'; @@ -157,7 +157,7 @@ public function __construct() } /** - * @return \Monolog\Logger + * @return \PrestaShop\Module\PsAccounts\Vendor\Monolog\Logger */ public function getLogger() { @@ -229,14 +229,14 @@ public function getCoreServiceContainer() } /** - * @return \PrestaShop\Module\PsAccounts\ServiceContainer\PsAccountsServiceContainer + * @return \PrestaShop\Module\PsAccounts\ServiceContainer\PsAccountsContainer * * @throws Exception */ public function getServiceContainer() { if (null === $this->moduleContainer) { - $this->moduleContainer = \PrestaShop\Module\PsAccounts\ServiceContainer\PsAccountsServiceContainer::createInstance( + $this->moduleContainer = \PrestaShop\Module\PsAccounts\ServiceContainer\PsAccountsContainer::createInstance( __DIR__ . '/config.php' ); } @@ -362,40 +362,6 @@ public function getContent() return $this->display(__FILE__, 'views/templates/admin/app.tpl'); } - /** - * @return mixed - * - * @throws Exception - */ - public function renderUpdateWarningView() - { - if ($this->getShopContext()->isShop173()) { - /* @phpstan-ignore-next-line */ - return PrestaShop\PrestaShop\Adapter\SymfonyContainer::getInstance() - ->get('twig') - ->render('@Modules/ps_accounts/views/templates/backoffice/update_url_warning.twig'); - } else { - return ''; - } - } - - /** - * @return mixed - * - * @throws Exception - */ - public function renderDeleteWarningView() - { - if ($this->getShopContext()->isShop173()) { - /* @phpstan-ignore-next-line */ - return PrestaShop\PrestaShop\Adapter\SymfonyContainer::getInstance() - ->get('twig') - ->render('@Modules/ps_accounts/views/templates/backoffice/delete_url_warning.twig'); - } else { - return ''; - } - } - /** * @return string */ diff --git a/scoper.inc.php b/scoper.inc.php index ef8b1ed27..65988f353 100644 --- a/scoper.inc.php +++ b/scoper.inc.php @@ -143,11 +143,12 @@ static function ($filePath, $prefix, $contents) { // // For more information see: https://github.com/humbug/php-scoper/blob/master/docs/configuration.md#excluded-symbols 'exclude-namespaces' => [ - '~^PrestaShop\\\\OAuth2\\\\Client~', + //'~^PrestaShop\\\\OAuth2\\\\Client~', '~^Composer\\\\~', - 'Monolog\\', + //'Monolog\\', //'~^Symfony\\\\Component\\\\Config~', - 'Symfony\\Component\\Config\\', + //'Symfony\\Component\\Config\\', + // Polyfills can't be scoped by essence 'Symfony\\Polyfill\\Apcu\\', 'Symfony\\Polyfill\\Ctype\\', 'Symfony\\Polyfill\\IntlIdn\\', diff --git a/src/Context/ShopContext.php b/src/Context/ShopContext.php index 0d1874499..c8576e2f4 100644 --- a/src/Context/ShopContext.php +++ b/src/Context/ShopContext.php @@ -164,8 +164,6 @@ public function getConfiguration() * @param \Closure $closure * * @return mixed - * - * @throws \Throwable|\Exception */ public function execInShopContext($shopId, $closure) { diff --git a/src/Exception/AccountLogin/AccountLoginException.php b/src/Exception/AccountLogin/AccountLoginException.php index b3df1cf55..de958d7a2 100644 --- a/src/Exception/AccountLogin/AccountLoginException.php +++ b/src/Exception/AccountLogin/AccountLoginException.php @@ -20,7 +20,7 @@ namespace PrestaShop\Module\PsAccounts\Exception\AccountLogin; -use PrestaShop\OAuth2\Client\Provider\PrestaShopUser; +use PrestaShop\Module\PsAccounts\Vendor\PrestaShop\OAuth2\Client\Provider\PrestaShopUser; class AccountLoginException extends \Exception { diff --git a/src/Exception/AccountLogin/EmailNotVerifiedException.php b/src/Exception/AccountLogin/EmailNotVerifiedException.php index 844cab17b..5721db765 100644 --- a/src/Exception/AccountLogin/EmailNotVerifiedException.php +++ b/src/Exception/AccountLogin/EmailNotVerifiedException.php @@ -20,7 +20,7 @@ namespace PrestaShop\Module\PsAccounts\Exception\AccountLogin; -use PrestaShop\OAuth2\Client\Provider\PrestaShopUser; +use PrestaShop\Module\PsAccounts\Vendor\PrestaShop\OAuth2\Client\Provider\PrestaShopUser; class EmailNotVerifiedException extends AccountLoginException { diff --git a/src/Exception/AccountLogin/EmployeeNotFoundException.php b/src/Exception/AccountLogin/EmployeeNotFoundException.php index 612e930e0..00acfa574 100644 --- a/src/Exception/AccountLogin/EmployeeNotFoundException.php +++ b/src/Exception/AccountLogin/EmployeeNotFoundException.php @@ -20,7 +20,7 @@ namespace PrestaShop\Module\PsAccounts\Exception\AccountLogin; -use PrestaShop\OAuth2\Client\Provider\PrestaShopUser; +use PrestaShop\Module\PsAccounts\Vendor\PrestaShop\OAuth2\Client\Provider\PrestaShopUser; class EmployeeNotFoundException extends AccountLoginException { diff --git a/src/Exception/AccountLogin/Oauth2Exception.php b/src/Exception/AccountLogin/Oauth2Exception.php index 10636ccc8..8c5acedca 100644 --- a/src/Exception/AccountLogin/Oauth2Exception.php +++ b/src/Exception/AccountLogin/Oauth2Exception.php @@ -20,7 +20,7 @@ namespace PrestaShop\Module\PsAccounts\Exception\AccountLogin; -use PrestaShop\OAuth2\Client\Provider\PrestaShopUser; +use PrestaShop\Module\PsAccounts\Vendor\PrestaShop\OAuth2\Client\Provider\PrestaShopUser; class Oauth2Exception extends AccountLoginException { diff --git a/src/Hook/DisplayAccountUpdateWarning.php b/src/Hook/DisplayAccountUpdateWarning.php index 97f14eb40..744af5c06 100644 --- a/src/Hook/DisplayAccountUpdateWarning.php +++ b/src/Hook/DisplayAccountUpdateWarning.php @@ -20,34 +20,39 @@ namespace PrestaShop\Module\PsAccounts\Hook; -use Exception; use PrestaShop\Module\PsAccounts\Service\PsAccountsService; class DisplayAccountUpdateWarning extends Hook { /** - * @var PsAccountsService - */ - private $accountsService; - - public function __construct(\Ps_accounts $module) - { - parent::__construct($module); - $this->accountsService = $this->module->getService(PsAccountsService::class); - } - - /** - * @return string + * @param array $params * - * @throws Exception + * @return string */ public function execute(array $params = []) { - if ($this->accountsService->isAccountLinked() && + /** @var PsAccountsService $accountsService */ + $accountsService = $this->module->getService(PsAccountsService::class); + + if ($accountsService->isAccountLinked() && !$this->module->getShopContext()->isMultishopActive()) { - // I don't load with $this->get('twig') since i had this error https://github.com/PrestaShop/PrestaShop/issues/20505 - // Some users may have the same and couldn't render the configuration page - return $this->module->renderUpdateWarningView(); + $msg = $this->module->l( + 'This shop is linked to your PrestaShop account. ' . + 'Unlink your shop if you do not want to impact your live settings.', + 'ps_accounts' + ); + + return << +
+ +
+ +HTML; } return ''; diff --git a/src/Hook/DisplayDashboardTop.php b/src/Hook/DisplayDashboardTop.php index 2edd98626..9bbfbf6e2 100644 --- a/src/Hook/DisplayDashboardTop.php +++ b/src/Hook/DisplayDashboardTop.php @@ -20,7 +20,6 @@ namespace PrestaShop\Module\PsAccounts\Hook; -use Exception; use PrestaShop\Module\PsAccounts\Context\ShopContext; use PrestaShop\Module\PsAccounts\Provider\ShopProvider; use PrestaShop\Module\PsAccounts\Service\PsAccountsService; @@ -31,8 +30,6 @@ class DisplayDashboardTop extends Hook * @param array $params * * @return mixed - * - * @throws Exception */ public function execute(array $params = []) { @@ -54,18 +51,16 @@ public function execute(array $params = []) * @param ShopContext $shopContext * @param PsAccountsService $accountsService * - * @return mixed - * - * @throws Exception + * @return string */ protected function renderAdminShopWarningIfLinked($shopContext, $accountsService) { if (isset($_GET['addshop'])) { - return; + return ''; } if (isset($_GET['updateshop'])) { - return; + return ''; } /** @var ShopProvider $shopProvider */ @@ -78,32 +73,66 @@ protected function renderAdminShopWarningIfLinked($shopContext, $accountsService return $accountsService->isAccountLinked(); }); if ($isLink) { - return $this->module->renderDeleteWarningView(); + $msg = $this->module->l( + 'Some shops are linked to your PrestaShop account. ' . + 'Delete these shops will impact your live settings.', + 'Modules.ps_accounts' + ); + + return << +
+ +
+ +HTML; } } } + + return ''; } /** * @param ShopContext $shopContext * @param PsAccountsService $accountsService * - * @return mixed - * - * @throws Exception + * @return string */ protected function renderAdminShopUrlWarningIfLinked($shopContext, $accountsService) { if (!isset($_GET['updateshop_url'])) { - return; + return ''; } $shopId = $shopContext->getShopIdFromShopUrlId((int) $_GET['id_shop_url']); return $shopContext->execInShopContext($shopId, function () use ($accountsService) { if ($accountsService->isAccountLinked()) { - return $this->module->renderUpdateWarningView(); + $msg = $this->module->l( + 'This shop is linked to your PrestaShop account. ' . + 'Unlink your shop if you do not want to impact your live settings.', + 'ps_accounts' + ); + + return << +
+ +
+ +HTML; } + + return ''; }); } } diff --git a/src/Hook/Hook.php b/src/Hook/Hook.php index b345a9a8c..bf5b1bd89 100644 --- a/src/Hook/Hook.php +++ b/src/Hook/Hook.php @@ -20,8 +20,8 @@ namespace PrestaShop\Module\PsAccounts\Hook; -use Monolog\Logger; use PrestaShop\Module\PsAccounts\Cqrs\CommandBus; +use PrestaShop\Module\PsAccounts\Vendor\Monolog\Logger; use Ps_accounts; abstract class Hook diff --git a/src/Log/Logger.php b/src/Log/Logger.php index 525fff1e9..a558378df 100644 --- a/src/Log/Logger.php +++ b/src/Log/Logger.php @@ -20,8 +20,8 @@ namespace PrestaShop\Module\PsAccounts\Log; -use Monolog\Handler\RotatingFileHandler; -use Monolog\Logger as MonologLogger; +use PrestaShop\Module\PsAccounts\Vendor\Monolog\Handler\RotatingFileHandler; +use PrestaShop\Module\PsAccounts\Vendor\Monolog\Logger as MonologLogger; use Ps_accounts; class Logger diff --git a/src/Presenter/DependenciesPresenter.php b/src/Presenter/DependenciesPresenter.php index c1446b438..f7428a382 100644 --- a/src/Presenter/DependenciesPresenter.php +++ b/src/Presenter/DependenciesPresenter.php @@ -25,6 +25,9 @@ use PrestaShop\Module\PsAccounts\Installer\Installer; use Ps_accounts; +/** + * @deprecated since v7.O.O + */ class DependenciesPresenter implements PresenterInterface { /** diff --git a/src/Provider/OAuth2/PrestaShopLoginTrait.php b/src/Provider/OAuth2/PrestaShopLoginTrait.php index df4071100..5d3e7f59a 100644 --- a/src/Provider/OAuth2/PrestaShopLoginTrait.php +++ b/src/Provider/OAuth2/PrestaShopLoginTrait.php @@ -26,7 +26,7 @@ use PrestaShop\Module\PsAccounts\Log\Logger; use PrestaShop\Module\PsAccounts\Vendor\League\OAuth2\Client\Provider\Exception\IdentityProviderException; use PrestaShop\Module\PsAccounts\Vendor\League\OAuth2\Client\Token\AccessToken; -use PrestaShop\OAuth2\Client\Provider\PrestaShopUser; +use PrestaShop\Module\PsAccounts\Vendor\PrestaShop\OAuth2\Client\Provider\PrestaShopUser; use Symfony\Component\HttpFoundation\Session\SessionInterface; use Tools; diff --git a/src/Provider/OAuth2/PrestaShopSession.php b/src/Provider/OAuth2/PrestaShopSession.php index 3b5c88476..6d55d8833 100644 --- a/src/Provider/OAuth2/PrestaShopSession.php +++ b/src/Provider/OAuth2/PrestaShopSession.php @@ -22,7 +22,7 @@ use PrestaShop\Module\PsAccounts\Vendor\League\OAuth2\Client\Provider\Exception\IdentityProviderException; use PrestaShop\Module\PsAccounts\Vendor\League\OAuth2\Client\Token\AccessToken; -use PrestaShop\OAuth2\Client\Provider\PrestaShopUser; +use PrestaShop\Module\PsAccounts\Vendor\PrestaShop\OAuth2\Client\Provider\PrestaShopUser; use Symfony\Component\HttpFoundation\Session\SessionInterface; class PrestaShopSession diff --git a/src/Provider/OAuth2/ShopProvider.php b/src/Provider/OAuth2/ShopProvider.php index a05e3c194..93b1e2827 100644 --- a/src/Provider/OAuth2/ShopProvider.php +++ b/src/Provider/OAuth2/ShopProvider.php @@ -22,7 +22,7 @@ use PrestaShop\Module\PsAccounts\Adapter\Link; use PrestaShop\Module\PsAccounts\Vendor\League\OAuth2\Client\Provider\AbstractProvider; -use PrestaShop\OAuth2\Client\Provider\PrestaShop; +use PrestaShop\Module\PsAccounts\Vendor\PrestaShop\OAuth2\Client\Provider\PrestaShop; class ShopProvider extends PrestaShop { diff --git a/src/Service/AnalyticsService.php b/src/Service/AnalyticsService.php index aca6f975b..9006852a9 100644 --- a/src/Service/AnalyticsService.php +++ b/src/Service/AnalyticsService.php @@ -20,7 +20,7 @@ namespace PrestaShop\Module\PsAccounts\Service; -use Monolog\Logger; +use PrestaShop\Module\PsAccounts\Vendor\Monolog\Logger; use PrestaShop\Module\PsAccounts\Vendor\Ramsey\Uuid\Uuid; use Segment; diff --git a/src/ServiceContainer/PsAccountsServiceContainer.php b/src/ServiceContainer/PsAccountsContainer.php similarity index 94% rename from src/ServiceContainer/PsAccountsServiceContainer.php rename to src/ServiceContainer/PsAccountsContainer.php index fa4351782..b297aa97f 100644 --- a/src/ServiceContainer/PsAccountsServiceContainer.php +++ b/src/ServiceContainer/PsAccountsContainer.php @@ -20,11 +20,11 @@ namespace PrestaShop\Module\PsAccounts\ServiceContainer; -use Monolog\Logger; use PrestaShop\Module\PsAccounts\Log\Logger as LoggerFactory; +use PrestaShop\Module\PsAccounts\Vendor\Monolog\Logger; use PrestaShop\Module\PsAccounts\Vendor\PrestaShopCorp\LightweightContainer\ServiceContainer\ServiceContainer; -class PsAccountsServiceContainer extends ServiceContainer +class PsAccountsContainer extends ServiceContainer { /** * @var Logger diff --git a/src/ServiceContainer/StaticProvider.php b/src/ServiceContainer/StaticProvider.php new file mode 100644 index 000000000..9afb08db0 --- /dev/null +++ b/src/ServiceContainer/StaticProvider.php @@ -0,0 +1,37 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace PrestaShop\Module\PsAccounts\ServiceContainer; + +class StaticProvider +{ + /** + * @param string $serviceName + * + * @return mixed + */ + public static function provide($serviceName) + { + /** @var \Ps_accounts $module */ + $module = \Module::getInstanceByName('ps_accounts'); + + return $module->getService($serviceName); + } +} diff --git a/views/templates/backoffice/delete_url_warning.twig b/views/templates/backoffice/delete_url_warning.twig deleted file mode 100644 index 171a61662..000000000 --- a/views/templates/backoffice/delete_url_warning.twig +++ /dev/null @@ -1,9 +0,0 @@ -
-
- -
-
diff --git a/views/templates/backoffice/update_url_warning.twig b/views/templates/backoffice/update_url_warning.twig deleted file mode 100644 index ba8bcd148..000000000 --- a/views/templates/backoffice/update_url_warning.twig +++ /dev/null @@ -1,9 +0,0 @@ -
-
- -
-