diff --git a/.docker/config-files/post-install.sh b/.docker/config-files/post-install.sh index 2dd4068..a0c104c 100644 --- a/.docker/config-files/post-install.sh +++ b/.docker/config-files/post-install.sh @@ -1,3 +1,5 @@ echo "BulkGate module - postinstall" -su -s /bin/bash www-data -c "bin/console prestashop:module install bg_prestasms" +su -s /bin/bash www-data -c "bin/console prestashop:module install bulkgate_sms_module_for_prestashop" + +exit 0 \ No newline at end of file diff --git a/.docker/config-files/pre-install.sh b/.docker/config-files/pre-install.sh index fc827e7..d4e8b1f 100644 --- a/.docker/config-files/pre-install.sh +++ b/.docker/config-files/pre-install.sh @@ -1,6 +1,8 @@ echo "PrestaSMS module - preinstall" -cd /var/www/html/modules/bg_prestasms -rm composer.lock -composer install --prefer-dist --no-progress --no-dev +cd /var/www/html/modules/bulkgate_sms_module_for_prestashop && \ +rm composer.lock && \ +composer install --prefer-dist --no-progress --no-dev && \ chown -R www-data:www-data vendor + +exit 0 \ No newline at end of file diff --git a/.docker/versions.json b/.docker/versions.json index 47235b2..c986164 100644 --- a/.docker/versions.json +++ b/.docker/versions.json @@ -18,5 +18,9 @@ { "php": "8.1", "prestashop": "8.2.1" + }, + { + "php": "8.4", + "prestashop": "9.0.0-1.0-classic" } ] \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 95abd12..ff424aa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,29 +7,29 @@ on: jobs: bundle: runs-on: ubuntu-latest - container: ghcr.io/bulkgate/prestasms:8.2.1-7.4 + container: ghcr.io/bulkgate/prestasms:1.7.8.0-7.4 env: GH_TOKEN: ${{github.token}} #required by gh cli steps: - uses: actions/checkout@v1 - name: Install packages - run: composer install --prefer-dist --no-progress --no-suggest + run: composer install --prefer-dist --no-progress - name: Apply code style run: composer run prestashop-lint - name: Keep only production dependencies - run: composer install --prefer-dist --no-progress --no-suggest --no-dev + run: composer install --prefer-dist --no-progress --no-dev - name: Create plugin directory - run: mkdir -p /tmp/bg_prestasms + run: mkdir -p /tmp/bulkgate_sms_module_for_prestashop - name: Copy plugin files - run: cp -r config controllers src translations vendor views logo.png LICENSE *.php composer.json /tmp/bg_prestasms + run: cp -r config controllers src translations vendor views logo.png LICENSE *.php composer.json /tmp/bulkgate_sms_module_for_prestashop - name: Create plugin zip - run: cd /tmp && zip -r bg_prestasms.zip bg_prestasms + run: cd /tmp && zip -r bulkgate_sms_module_for_prestashop.zip bulkgate_sms_module_for_prestashop - name: Install GitHub CLI run: | @@ -42,4 +42,4 @@ jobs: apt-get install -y gh - name: Add zip to release - run: gh release upload ${{github.ref_name}} /tmp/bg_prestasms.zip \ No newline at end of file + run: gh release upload ${{github.ref_name}} /tmp/bulkgate_sms_module_for_prestashop.zip \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 479b6f0..39b0de0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -26,6 +26,8 @@ jobs: prestashop: 8.2.1 - php: 8.1 prestashop: 8.2.1 + - php: 8.4 + prestashop: 9.0.0-1.0-classic container: ghcr.io/bulkgate/prestasms:${{ matrix.prestashop }}-${{ matrix.php }} @@ -39,12 +41,22 @@ jobs: run: composer run tester - name: Run static analysis - run: composer run phpstan + shell: bash + run: | + if [[ "${{ matrix.prestashop }}" == 1.7.* ]]; then + composer run phpstan -- -c phpstan7.neon + elif [[ "${{ matrix.prestashop }}" == 8.* ]]; then + composer run phpstan -- -c phpstan8.neon + elif [[ "${{ matrix.prestashop }}" == 9.* ]]; then + composer run phpstan -- -c phpstan9.neon + else + composer run phpstan + fi coverage: runs-on: ubuntu-latest - container: ghcr.io/bulkgate/prestasms:8.2.1-8.1 + container: ghcr.io/bulkgate/prestasms:9.0.0-1.0-classic-8.4 steps: - uses: actions/checkout@v2 diff --git a/README.md b/README.md index 67e8167..cd77e20 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ Pokud potřebuješ spustit více instancí s různými verzemi nebo parametry na ```shell MYSQL_DATABASE=prestashop_7 ADMINER_PORT=9070 PRESTASHOP_IMAGE_VERSION=1.7.8.0-7.4 PRESTASHOP_DOMAIN=ps7.dev.bulkgate.com:8070 PRESTASHOP_PORT=8070 docker compose --project-name ps_1_7 up -d MYSQL_DATABASE=prestashop_8 ADMINER_PORT=9080 PRESTASHOP_IMAGE_VERSION=8.2.1-7.4 PRESTASHOP_DOMAIN=ps8.dev.bulkgate.com:8080 PRESTASHOP_PORT=8080 docker compose --project-name ps_8_2 up -d +MYSQL_DATABASE=prestashop_9 ADMINER_PORT=9090 PRESTASHOP_IMAGE_VERSION=9.0.0-1.0-classic-8.4 PRESTASHOP_DOMAIN=localhost:8090 PRESTASHOP_PORT=8090 docker compose --project-name ps_9_0 up -d ``` Aby ti fungovalo napovídání v IDE (prestashop source code), musíš namountovat instalaci prestashopu z kontejneru na disk. @@ -25,18 +26,6 @@ rm -rf prestashop config*.xml > Je to z toho duvodu, ze prestashop je v tuto chvili persistentne ulozen v adresari prestashop na tvojem disku a image by tak pri startupu neprovedl instalaci! > Soubory config.xml vznikaji prave pri instalaci modulu a je lepsi je take odstranit. -## Known bugs - -### Auto instalace modulu -Instalace modulu probehne v poradku (podle vypisu z console behem startupu kontejneru), ale modul nefunguje. -```text -You have requested a non-existent service "PrestaShop\PrestaShop\Adapter\Shop\Url\BaseUrlProvider" -``` -Toto se vyresi jednoduse tak, ze v kontejneru spustis: -```shell -/tmp/post-install-scripts/post-install.sh -``` - ## PrestaShop - [Documentation for developers](https://devdocs.prestashop-project.org/8/modules/creation/tutorial/) - [Legacy/Core/Adapter/PrestaShopBundle](https://devdocs.prestashop-project.org/1.7/development/architecture/file-structure/understanding-src-folder/) @@ -46,176 +35,3 @@ Toto se vyresi jednoduse tak, ze v kontejneru spustis: ## Doctrine - [Documentation for doctrine](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/data-retrieval-and-manipulation.html#executestatement) -Nektere sluzby v PrestaShopu maji pouze identifikator v ramci DI kontejneru (prestashop.adapter.data_provider.order_state, atd...). To znamena, ze pokud k nim nechceme pristupovat pres ServiceLocator, -musime jim vytvorit alias. - -```yml -PrestaShop\PrestaShop\Adapter\OrderState\OrderStateDataProvider: '@prestashop.adapter.data_provider.order_state' -``` ->Takto budu moct pouzit sluzbu pomoci type hintu :) - -## Common errors -Expected to find class "XXX" in file "xxx" while importing services from resource "../src/", but it was not found! Check the namespace prefix used with the resource. -> nejspis jsme zapomneli spustit: composer dumpautoload - -## bin/console -CLI nastroj pro prestashop (instalace, odinstalace modulu, atd...) -```sh -sudo -u www-data bash # prihlasim se pod www-data usera -bin/console prestashop:module install bg_prestasms -# Toto by se mohlo vyresit rovnou ve sluzbe prestashop v docker-compose -``` - - -# External Links -- [platform stats](https://storeleads.app/reports/prestashop) -- [https://www.prestasoo.com/](https://www.prestasoo.com/) - -# TODO automatizace vs (admin/customer sms) -Aktualne se za pojem **automatizace** berou admin/customer sms. V blizke budoucnosti se ale automatizace zobecni a bude potreba lepe strukturovat data a tim padem prijit s lepsim API nez s Variables. -Ty bouzel funguji pouze na principu sberneho obejktu, ale uplne jim chybi kontext a treba taky pokrocilejsi metody (flatten -> podpora stavajiciho formatu). - -Jak si dokazu predstavit "nove" Variables? - -## Context index -V principu je to docela podobny koncept graphQL. Kontext tvori zakladni informace (strukturu) o tom, co se bude nacitat. -Kontext je vstup pro loader, ktery na zaklade klicu a hodnot kontextu bude moci naplnit struktury kontextu. - -- id_shop -> id obchodu pro ktery kontext plati -- id_lang -> id jazyku pro ktery kontext plati -- id_currency -> id meny pro kterou kontext plati -- id_carrier -> id dopravce pro ktereho kontext plati -- id_order -> id objednavky pro ktery kontext plati -- id_product -> id produktu pro ktery kontext plati -- id_cart -> id kosiku pro ktery kontext plati -- id_user -> id uzivatele pro ktery kontext plati - - -### Příklad definice kontextu (index) -Takto může vypadat struktura kontextu - -```json5 -{ - id_shop: 1, - id_lang: 1, - order: { - id_order: 5, - id_lang: 1, - id_product: [20, 30], - id_carrier: 3, - }, -} -``` - -### Příklad načteného kontextu (resolved) -Takto může vypadat struktura resolvnutého indexu kontextu. - -```json5 -{ - shop: { //id_shop: 1 - id: 1, - name: "Alza.cz", - email: "support@alza.cz", - currency: "CZK", - phone: "800-600-500", - url: "https://www.alza.cz" - }, - lang: { //id_lang: 1 - id: 1, - iso: "cs" - }, - order: { //literal key - id: 3, - currency: "CZK", - date: "2025-01-23T06:11:00.000Z", - price: 169.9, //value in order currency - lang: { //id_lang: 1 - id: 1, - iso: "cs" - }, - product: [ //id_product: [20, 30] - { - id: 20, - quantity: 2, - price: 11.9, //value in order currency - name: "Mug Today is a good day", - reference: "demo_13" - }, - { - id: 30, - quantity: 1, - price: 19.12, //value in order currency - name: "Hummingbird printed t-shirt (Size: S - Color: Black)", - reference: "demo_1" - } - ], - carrier: { //id_carrier: 3 - price: 0, //relative to order - name: "DPD", - url: "https://dpd.com/tracinking/AXJFGKLOURT", - weight: 300, //grams - tracking_number: "AXJFGKLOURT", - tracking_date: "2025-01-23T12:45:00.000Z" - } - } -} -``` -### Vyhody nevyhody -- Samotne rozdeleni do kontextu ma pozitivni vliv na omezeni vyberu promennych. Uzivatel muze pracovat pouze s promennymi, ktere nabizi kontext, nebo ktere se daji na zaklade kontextu derivovat (foreach ,filtry, formatovace) -- Data budou vzdy strukturovana, takze budeme posilat mensi pocet dat (bez formatovacu a filtru) a budeme schopni vytvorit odpovidajici datove typy s truktury, ktere mohou byt zdokumentovany - -### Automatizace todo -- kazda automatizace bude mit svuj vlastni soubor (neco jako github actions) -- budu mit prehled o vsech spustenych instancich s tim, ze se budu moci podivat i na automatizacni graf (tzn. presne budu videt kam se interpret dostal a jake mel k dispozici data) -- napriklad z detailu (objednavky, kosiku, uzivatele atd..) budu moct otestovat automatizaci -> simulovat. Tim si vyzkousim nastaveni na realnych datech... -- kazda eshop platforma muze (a asi bude) mit vlastni automatizacni soubor, protoze moznosti kazde platformy jsou ruzne. -- mely by se automatizace verzovat (source)? Melo by verzovani byt na zaklade features/deprecations na dane platforme? -- pokud uzivatel vytvori automatizaci a nasledne ji bude spravovat, budou se tyto zmeny verzovat (stejne jako GTM)? -- pokud si uzivatel bude chtit otestovat automatizaci bude to spoustet dummy a nebo realne triggery? -- budou instance automatizaci bezet v dockeru? - - prestashop-1.7 -> /app/model/automation/prestashop/1.7/ -> docker compose run prestashop-1.7 - - prestashop-8 -> /app/model/automation/prestashop/8/ -> docker compose run prestashop-8.0 -> volume bude vest ke zdrojovym souborum automatizace (runtime, triggery) -- docker image: - - bude postaveny tak, aby se dal jednoduse zkonfigurovat (db connection, rabbit connection, network etc...) - - vice mene to bude konzolove php, protoze neni duvod vyuzivat serverove - - automatizace by se spoustely cronem ze strany bulkgate. Je otazka jestli je poustet primo. Abychom zajistili bezpecnost a asynchronni chovani - -Příklad toho, jak by se mohla volat automatizace - -/api/1.0/eshop/automation/run/ -```json5 -{ - context: CONTEXT_INDEX, - data: CONTEXT_INDEX_RESOLVED -} -``` - -# TODO -- docker image: vytvorit image, ktery bude resit (PHP_VERSION, PRESTASHOP_VERSION). Verze modulu je dana gitem. v pripade wordpressu to bude WORDPRESS_VERSION + WOOCOMMERCE_VERSION -- pri spusteni modulu (login) se neprenesou data modulu (pokud nejsou). Az po refreshi se nactou. To je lehce bug, protoze data muzou byt jina kvuli napr. synchronizaci... -- novy hook actionCustomerAccountUpdate -> muzeme aktualizovat informace o uzivateli -- preklady https://devdocs.prestashop-project.org/8/modules/creation/module-translation/new-system/ -- zvalidovat modul oproti implementacim nativnich modulu napr. https://github.com/PrestaShop/example-modules/tree/master/demovieworderhooks -- dodelat nove metody - isLoggedIn atp ... budou to jenom ciste obalky nad standardnim $settings->load('static:token') -- proverit asynchronous order = -1 -> toto se stane, kdyz nastane chyba behem zpracovani. Musime zajistit, ze se tasky opet odeslou -- ~~zkusit marketing opt-in v checkoutu~~ -- ~~dodelat cron~~ -- ~~dopsat testy~~ -- ~~sloty ve web komponente - detail objednavky SEND message button ?~~ Jeste je potreba zjistit, jak by se jednoduse daly navesit event handlery v ramci reactu pro slotted element resp. pokud navesim na , tak chci, aby se event propagoval... -- ~~zprovoznit vsechny hooky~~ -- ~~overit proxyRedirect v pripade zmeny jazyku v settings 192.168.32.3~~ -- ~~zbavit se custom AsynchronousDatabase~~ -- ~~implementovat rozhrani databaze~~ -- ~~defaultni hodnoty pro nastaveni~~ -- ~~browser asset cron nacitat i v admin casti~~ -- ~~Lifecycle modulu (instalace, odinstalace, aktivace, deaktivace) Legacy environment https://devdocs.prestashop-project.org/1.7/modules/concepts/services/#services-in-legacy-environment -> musime doladit Module class~~ - - ~~usporadat service config podle legacy environmentu (abychom mohli prave v Modulu a na frontu pouzivat DI kontejner s nasema sluzbama)~~ - - ~~pouzit tabs zpusob pro definovani menu~~ -- Hooky - - ~~asset, cron, direct -> https://devdocs.prestashop-project.org/8/modules/creation/displaying-content-in-front-office/~~ - - ~~napojeni na kontejner~~ -# bugs: -- ~~UrlGeneratorInterface::ABSOLUTE_URL -> potrebujeme pri odhlaseni a prihlaseni, aby aplikace spravne presmerovavala. // https://github.com/PrestaShop/PrestaShop/issues/18703 - z nejakeho duvodu proste nefunguje ABSOLUTE_URL~~ vyresilo se tak, ze se pouze meni url SPA. -- ~~pri prihlaseni modulu se nekdy zobrazuje last sync jako 01.01.1970~~ -- ~~[Prestashop] pokud je aktivovany (default) Advanced parameters > Security > Back office token protection, tak router negeneruje ABSOLUTE_URL. To potom spatne funguje v pripadech, kdy potrebujeme hard reload (viz. zmena jazyka)~~ -- [module:plugin] kdyz neni nastaveno synchronize="all", tak se potom nereflektuji automatizace. Na frontendu sice jdou videt (data z portalu), ale v modulu se realne nespusti! Je to z duvodu jak je implementovana metoda BulkGate\Plugin\Event\Dispatcher::check!! -Je to optimalizace kvuli rychlosti. Takhle ovsem o tom, co se odeslalo rozhodl modul, protoze vedel co ma nastaveno. Nyni to vsak vedet nebude, tim padem o tom bude muset rozhodnout BG. Mohlo by to do jiste miry mit i vyhodu v tom, ze si uzivatel toto bude moct nastavit na BG. diff --git a/bg_prestasms.php b/bulkgate_sms_module_for_prestashop.php similarity index 99% rename from bg_prestasms.php rename to bulkgate_sms_module_for_prestashop.php index b9c88fd..d8c62b6 100644 --- a/bg_prestasms.php +++ b/bulkgate_sms_module_for_prestashop.php @@ -16,7 +16,7 @@ * * @see https://www.bulkgate.com/ */ -class Bg_PrestaSms extends Module +class BulkGate_Sms_Module_For_Prestashop extends Module { use Container; @@ -43,7 +43,7 @@ class Bg_PrestaSms extends Module public function __construct() { - $this->name = 'bg_prestasms'; + $this->name = 'bulkgate_sms_module_for_prestashop'; $this->tab = 'emailing'; $this->version = BulkGateModuleVersion; $this->author = BulkGateWhiteLabel; diff --git a/composer.json b/composer.json index 7026179..8edeed2 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "bulkgate/prestasms", - "type": "project", + "type": "prestashop-module", "minimum-stability": "RC", "require": { "php": ">= 7.4", @@ -25,9 +25,8 @@ }, "scripts": { "tester": "tester -C tests --colors=1", - "coverage": "tester -C tests --coverage=coverage.html --coverage-src=src --stop-on-fail -o console-lines", + "coverage": "tester -C tests --coverage=coverage.html --coverage-src=src --stop-on-fail -o console", "phpstan": "phpstan analyse -c phpstan.neon --memory-limit=1G", - "phpstan-baseline": "phpstan analyse -c phpstan.neon --memory-limit=1G --generate-baseline", "prestashop-lint": "php-cs-fixer fix" }, "config": { diff --git a/config/common.yml b/config/common.yml index dd7287c..d03c0c2 100644 --- a/config/common.yml +++ b/config/common.yml @@ -1,28 +1,7 @@ services: - _defaults: - autowire: true - autoconfigure: true - public: true - - # Adapter classes services - - PrestaShop\PrestaShop\Adapter\OrderState\OrderStateDataProvider: - class: PrestaShop\PrestaShop\Adapter\OrderState\OrderStateDataProvider - PrestaShop\PrestaShop\Adapter\OrderReturnState\OrderReturnStateDataProvider: - class: PrestaShop\PrestaShop\Adapter\OrderReturnState\OrderReturnStateDataProvider - PrestaShop\PrestaShop\Adapter\Shop\Context: - class: PrestaShop\PrestaShop\Adapter\Shop\Context - PrestaShop\PrestaShop\Adapter\Shop\Url\BaseUrlProvider: - class: PrestaShop\PrestaShop\Adapter\Shop\Url\BaseUrlProvider - arguments: - - "@=service('prestashop.adapter.legacy.context').getContext().link" - PrestaShop\PrestaShop\Adapter\Employee\ContextEmployeeProvider: - class: PrestaShop\PrestaShop\Adapter\Employee\ContextEmployeeProvider - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext().employee' # Symfony Controller - https://devdocs.prestashop-project.org/1.7/modules/concepts/controllers/admin-controllers/#how-to-declare-a-new-controller - BulkGate\PrestaShop\Controller\AdminController: class: BulkGate\PrestaShop\Controller\AdminController + autowire: false tags: [ controller.service_arguments ] diff --git a/config/routes.yml b/config/routes.yml index 9cee366..ada0edd 100644 --- a/config/routes.yml +++ b/config/routes.yml @@ -1,6 +1,6 @@ # @see [_lagacy_link](https://devdocs.prestashop-project.org/1.7/modules/concepts/controllers/admin-controllers/tabs/) bulkgate_main_app: - path: prestasms + path: bulkgate-sms methods: [GET] defaults: _controller: 'BulkGate\PrestaShop\Controller\AdminController::indexAction' @@ -8,13 +8,13 @@ bulkgate_main_app: _legacy_link: AdminBulkGateConfigure bulkgate_proxy: - path: prestasms/proxy-{action} + path: bulkgate-sms/proxy-{action} methods: [POST] defaults: _controller: 'BulkGate\PrestaShop\Controller\AdminController::proxyAction' bulkgate_debug: - path: prestasms/debug + path: bulkgate-sms/debug methods: [GET] defaults: _controller: 'BulkGate\PrestaShop\Controller\AdminController::debugAction' diff --git a/controllers/front/AsynchronousAsset.php b/controllers/front/AsynchronousAsset.php index e652de8..72f7cb9 100644 --- a/controllers/front/AsynchronousAsset.php +++ b/controllers/front/AsynchronousAsset.php @@ -10,7 +10,7 @@ * * @see https://www.bulkgate.com/ */ -class bg_prestasmsAsynchronousAssetModuleFrontController extends ModuleFrontController +class bulkgate_sms_module_for_prestashopAsynchronousAssetModuleFrontController extends ModuleFrontController { use Container; diff --git a/controllers/front/Cron.php b/controllers/front/Cron.php index 4b3475f..222f0c3 100644 --- a/controllers/front/Cron.php +++ b/controllers/front/Cron.php @@ -10,7 +10,7 @@ * * @see https://www.bulkgate.com/ */ -class bg_prestasmsCronModuleFrontController extends ModuleFrontController +class bulkgate_sms_module_for_prestashopCronModuleFrontController extends ModuleFrontController { use Container; public $auth = false; diff --git a/cron.php b/cron.php index bb73cbb..bf0caf1 100644 --- a/cron.php +++ b/cron.php @@ -9,7 +9,7 @@ * @see https://devdocs.prestashop-project.org/8/modules/concepts/controllers/front-controllers/#using-a-front-controller-as-a-cron-task */ $_GET['fc'] = 'module'; -$_GET['module'] = 'bg_prestasms'; +$_GET['module'] = 'bulkgate_sms_module_for_prestashop'; $_GET['controller'] = 'Cron'; require_once __DIR__ . '/../../index.php'; // require diff --git a/distribution.php b/distribution.php index e6de6c7..7be65f8 100644 --- a/distribution.php +++ b/distribution.php @@ -20,7 +20,7 @@ /** * Internals */ -const BulkGateModuleVersion = '6.0.0'; +const BulkGateModuleVersion = '6.0.0-RC4'; const BulkGateMinimalPrestashopVersion = '1.7.8.0'; diff --git a/docker-compose.yml b/docker-compose.yml index 4673c25..0321565 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,8 +13,8 @@ services: extra_hosts: - "host.docker.internal:host-gateway" volumes: - - .:/var/www/html/modules/bg_prestasms - - /var/www/html/modules/bg_prestasms/vendor # volume mount override - not mounting vendor + - .:/var/www/html/modules/bulkgate_sms_module_for_prestashop + - /var/www/html/modules/bulkgate_sms_module_for_prestashop/vendor # volume mount override - not mounting vendor db: image: mariadb:10 diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon deleted file mode 100644 index 3f0fafa..0000000 --- a/phpstan-baseline.neon +++ /dev/null @@ -1,49 +0,0 @@ -parameters: - ignoreErrors: - - - message: '#^Cannot call method getLanguage\(\) on object\|null\.$#' - identifier: method.nonObject - count: 1 - path: src/DI/Factory.php - - - - message: '#^Parameter \#1 \$multistore of class BulkGate\\PrestaShop\\Eshop\\MultiStore constructor expects PrestaShop\\PrestaShop\\Core\\Multistore\\MultistoreContextCheckerInterface, object\|null given\.$#' - identifier: argument.type - count: 1 - path: src/DI/Factory.php - - - - message: '#^Parameter \#1 \$order_state of class BulkGate\\PrestaShop\\Eshop\\OrderStatus constructor expects PrestaShop\\PrestaShop\\Adapter\\OrderState\\OrderStateDataProvider, object\|null given\.$#' - identifier: argument.type - count: 1 - path: src/DI/Factory.php - - - - message: '#^Parameter \#1 \$order_state of class BulkGate\\PrestaShop\\Eshop\\ReturnStatus constructor expects PrestaShop\\PrestaShop\\Adapter\\OrderReturnState\\OrderReturnStateDataProvider, object\|null given\.$#' - identifier: argument.type - count: 1 - path: src/DI/Factory.php - - - - message: '#^Parameter \#2 \$employee of class BulkGate\\PrestaShop\\Eshop\\OrderStatus constructor expects PrestaShop\\PrestaShop\\Adapter\\Employee\\ContextEmployeeProvider, object\|null given\.$#' - identifier: argument.type - count: 1 - path: src/DI/Factory.php - - - - message: '#^Parameter \#2 \$employee of class BulkGate\\PrestaShop\\Eshop\\ReturnStatus constructor expects PrestaShop\\PrestaShop\\Adapter\\Employee\\ContextEmployeeProvider, object\|null given\.$#' - identifier: argument.type - count: 1 - path: src/DI/Factory.php - - - - message: '#^Parameter \#2 \$url_provider of class BulkGate\\PrestaShop\\Eshop\\Configuration constructor expects PrestaShop\\PrestaShop\\Adapter\\Shop\\Url\\BaseUrlProvider, object\|null given\.$#' - identifier: argument.type - count: 1 - path: src/DI/Factory.php - - - - message: '#^Parameter \#3 \$shop of class BulkGate\\PrestaShop\\Eshop\\Configuration constructor expects PrestaShop\\PrestaShop\\Adapter\\Shop\\Context, object\|null given\.$#' - identifier: argument.type - count: 1 - path: src/DI/Factory.php diff --git a/phpstan-baseline7.neon b/phpstan-baseline7.neon new file mode 100644 index 0000000..92be2b1 --- /dev/null +++ b/phpstan-baseline7.neon @@ -0,0 +1,7 @@ +parameters: + ignoreErrors: + - + message: '#^Parameter \#1 \$contextEmployee of class PrestaShop\\PrestaShop\\Adapter\\Employee\\ContextEmployeeProvider constructor expects Employee, Employee\|null given\.$#' + identifier: argument.type + count: 1 + path: src/DI/Factory.php diff --git a/phpstan-baseline8.neon b/phpstan-baseline8.neon new file mode 100644 index 0000000..a9454ce --- /dev/null +++ b/phpstan-baseline8.neon @@ -0,0 +1,13 @@ +parameters: + ignoreErrors: + - + message: '#^Parameter \#1 \$contextEmployee of class PrestaShop\\PrestaShop\\Adapter\\Employee\\ContextEmployeeProvider constructor expects Employee, Employee\|null given\.$#' + identifier: argument.type + count: 1 + path: src/DI/Factory.php + + - + message: '#^Parameter \#1 \$link of class PrestaShop\\PrestaShop\\Adapter\\Shop\\Url\\BaseUrlProvider constructor expects Link, Link\|null given\.$#' + identifier: argument.type + count: 1 + path: src/DI/Factory.php diff --git a/phpstan-baseline9.neon b/phpstan-baseline9.neon new file mode 100644 index 0000000..49fe471 --- /dev/null +++ b/phpstan-baseline9.neon @@ -0,0 +1,7 @@ +parameters: + ignoreErrors: + - + message: '#^Parameter \#1 \$link of class PrestaShop\\PrestaShop\\Adapter\\Shop\\Url\\BaseUrlProvider constructor expects Link, Link\|null given\.$#' + identifier: argument.type + count: 1 + path: src/DI/Factory.php diff --git a/phpstan.neon b/phpstan.neon index f90ede5..7c93c65 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,6 +1,3 @@ -includes: - - phpstan-baseline.neon - parameters: level: 8 paths: diff --git a/phpstan7.neon b/phpstan7.neon new file mode 100644 index 0000000..064e38c --- /dev/null +++ b/phpstan7.neon @@ -0,0 +1,3 @@ +includes: + - phpstan.neon + - phpstan-baseline7.neon \ No newline at end of file diff --git a/phpstan8.neon b/phpstan8.neon new file mode 100644 index 0000000..b0be38b --- /dev/null +++ b/phpstan8.neon @@ -0,0 +1,3 @@ +includes: + - phpstan.neon + - phpstan-baseline8.neon \ No newline at end of file diff --git a/phpstan9.neon b/phpstan9.neon new file mode 100644 index 0000000..76d3857 --- /dev/null +++ b/phpstan9.neon @@ -0,0 +1,3 @@ +includes: + - phpstan.neon + - phpstan-baseline9.neon \ No newline at end of file diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php index 89832d3..b0efd58 100644 --- a/src/Controller/AdminController.php +++ b/src/Controller/AdminController.php @@ -34,7 +34,7 @@ public function indexAction(): Response $token = $sign->authenticate(false, ['expire' => time() + 300]); - return $this->render('@Modules/bg_prestasms/views/templates/admin/index.html.twig', [ + return $this->render('@Modules/bulkgate_sms_module_for_prestashop/views/templates/admin/index.html.twig', [ 'layoutTitle' => BulkGateWhiteLabel . ' SMS', 'showContentHeader' => false, 'token' => $token, @@ -55,7 +55,7 @@ public function debugAction(): Response $requirements->same(true, version_compare($logger->platform_version, BulkGateMinimalPrestashopVersion, '>='), 'Prestashop ver. >= ' . BulkGateMinimalPrestashopVersion), ]); - return $this->render('@Modules/bg_prestasms/views/templates/admin/debug.html.twig', [ + return $this->render('@Modules/bulkgate_sms_module_for_prestashop/views/templates/admin/debug.html.twig', [ 'layoutTitle' => 'BulkGate SMS - debug', 'php_version' => phpversion(), 'prestashop_version' => _PS_VERSION_, diff --git a/src/DI/Factory.php b/src/DI/Factory.php index c064e64..1ad08a9 100644 --- a/src/DI/Factory.php +++ b/src/DI/Factory.php @@ -5,14 +5,15 @@ namespace BulkGate\PrestaShop\DI; use BulkGate\Plugin; -use BulkGate\PrestaShop\Ajax; use BulkGate\Plugin\Event\Dispatcher; +use BulkGate\PrestaShop\Ajax; use BulkGate\PrestaShop\Database\Connection; use BulkGate\PrestaShop\Eshop; use BulkGate\PrestaShop\Event; -use PrestaShop\PrestaShop\Adapter\Shop\Context; use PrestaShop\PrestaShop\Adapter\Employee\ContextEmployeeProvider; use PrestaShop\PrestaShop\Adapter\OrderReturnState\OrderReturnStateDataProvider; +use PrestaShop\PrestaShop\Adapter\Shop\Context; +use PrestaShop\PrestaShop\Adapter\LegacyContext; use PrestaShop\PrestaShop\Adapter\OrderState\OrderStateDataProvider; use PrestaShop\PrestaShop\Adapter\Shop\Url\BaseUrlProvider; use Symfony\Component\DependencyInjection\Container as SymfonyContainer; @@ -24,128 +25,138 @@ */ class Factory implements Plugin\DI\Factory { - use Plugin\Strict; - use Plugin\DI\FactoryStatic; - - /** - * @param array $parameters - */ - protected static function createContainer(array $parameters = []): Plugin\DI\Container - { - /** - * @var SymfonyContainer $symfony_di - */ - ['symfony_di' => $symfony_di] = $parameters; - - $container = new Plugin\DI\Container($parameters['mode'] ?? 'strict'); - - // Database - $container['database.connection'] = ['factory' => Connection::class, 'parameters' => ['db' => $symfony_di->get('doctrine.dbal.default_connection')]]; - - // Debug - $container['debug.repository.logger'] = ['factory' => Plugin\Debug\Repository\LoggerSettings::class, 'factory_method' => function () use ($container, $parameters): Plugin\Debug\Repository\LoggerSettings { - $logger = new Plugin\Debug\Repository\LoggerSettings($container->getByClass(Plugin\Settings\Settings::class)); - $logger->setup(is_int($parameters['logger_limit'] ?? null) ? $parameters['logger_limit'] : 100); - - return $logger; - }]; - $container['debug.logger'] = ['factory' => Plugin\Debug\Logger::class, 'parameters' => ['platform_version' => $parameters['platform_version'], 'module_version' => $parameters['module_version']]]; - $container['debug.requirements'] = Plugin\Debug\Requirements::class; - - // Ajax - $container['ajax.authenticate'] = Ajax\Authenticate::class; - $container['ajax.plugin_settings'] = Ajax\PluginSettingsChange::class; - - // Eshop - $container['eshop.configuration'] = ['factory' => Eshop\Configuration::class, 'factory_method' => fn () => new Eshop\Configuration( - $parameters['module_version'], - $symfony_di->get(BaseUrlProvider::class), - $symfony_di->get(Context::class) - )]; - $container['eshop.synchronizer'] = Plugin\Eshop\EshopSynchronizer::class; - $container['eshop.order_status'] = ['factory' => Eshop\OrderStatus::class, 'factory_method' => fn () => new Eshop\OrderStatus( - $symfony_di->get(OrderStateDataProvider::class), - $symfony_di->get(ContextEmployeeProvider::class) - )]; - $container['eshop.return_status'] = ['factory' => Eshop\ReturnStatus::class, 'factory_method' => fn () => new Eshop\ReturnStatus( - $symfony_di->get(OrderReturnStateDataProvider::class), - $symfony_di->get(ContextEmployeeProvider::class) - )]; - $container['eshop.language'] = Eshop\Language::class; - $container['eshop.multistore'] = ['factory' => Eshop\MultiStore::class, 'factory_method' => fn () => new Eshop\MultiStore( - $symfony_di->get(Context::class) - )]; - - // Event loaders - $container['event.loader.extension'] = ['factory' => Event\Loader\Extension::class, 'auto_wiring' => false]; - $container['event.loader.shop'] = ['factory' => Event\Loader\Shop::class, 'auto_wiring' => false]; - $container['event.loader.order'] = ['factory' => Event\Loader\Order::class, 'auto_wiring' => false]; - $container['event.loader.order_status'] = ['factory' => Event\Loader\OrderStatus::class, 'auto_wiring' => false]; - $container['event.loader.customer'] = ['factory' => Event\Loader\Customer::class, 'auto_wiring' => false]; - $container['event.loader.product'] = ['factory' => Event\Loader\Product::class, 'auto_wiring' => false]; - $container['event.loader.post'] = ['factory' => Event\Loader\Post::class, 'auto_wiring' => false]; - $container['event.loader'] = ['factory' => Plugin\Event\Loader::class, 'factory_method' => fn () => new Plugin\Event\Loader([ - $container->getByClass(Event\Loader\Order::class), - $container->getByClass(Event\Loader\OrderStatus::class), - $container->getByClass(Event\Loader\Customer::class), - $container->getByClass(Event\Loader\Shop::class), - $container->getByClass(Event\Loader\Product::class), - $container->getByClass(Event\Loader\Post::class), - $container->getByClass(Event\Loader\Extension::class), - ])]; - $container['event.dispatcher'] = Dispatcher::class; - - if (in_array($parameters['dispatcher'] ?? null, [Dispatcher::Asset, Dispatcher::Cron, Dispatcher::Direct], true)) - { - Dispatcher::$default_dispatcher = $parameters['dispatcher']; - } - - // Event - $container['event.hook'] = ['factory' => Plugin\Event\Hook::class, 'parameters' => ['version' => $parameters['api_version'] ?? '1.0']]; - $container['event.asynchronous.repository'] = Plugin\Event\Repository\AsynchronousDatabase::class; - $container['event.asynchronous'] = Plugin\Event\Asynchronous::class; - - // IO - $container['io.connection.factory'] = ['factory' => Plugin\IO\ConnectionFactory::class, 'factory_method' => function () use ($container): Plugin\IO\ConnectionFactory { - $configuration = $container->getByClass(Eshop\Configuration::class); - - return new Plugin\IO\ConnectionFactory($configuration->url(), $configuration->product(), $container->getByClass(Plugin\Settings\Settings::class)); - }]; - $container['io.connection'] = ['factory' => Plugin\IO\Connection::class, 'factory_method' => fn () => $container->getByClass(Plugin\IO\ConnectionFactory::class)->create()]; - $container['io.url'] = ['factory' => Plugin\IO\Url::class, 'parameters' => ['url' => $parameters['gate_url'] ?? 'https://portal.bulkgate.com']]; - - // Localization - $iso = $container->getByClass(Eshop\Language::class)->get($symfony_di->get('prestashop.adapter.legacy.context')->getLanguage()->getId()); // pozor! bezi v ruznych kontextech FO a BO - $container['localization.language'] = ['factory' => Plugin\Localization\LanguageSettings::class, 'parameters' => ['iso' => $iso]]; - $container['localization.translator'] = Plugin\Localization\TranslatorSettings::class; - $container['localization.formatter'] = extension_loaded('intl') ? ['factory' => Plugin\Localization\FormatterIntl::class, 'factory_method' => fn () => new Plugin\Localization\FormatterIntl($iso)] : Plugin\Localization\FormatterBasic::class; - - // Settings - $container['settings.repository.database'] = Plugin\Settings\Repository\SettingsDatabase::class; - $container['settings.repository.synchronizer'] = Plugin\Settings\Repository\SynchronizationDatabase::class; - $container['settings.settings'] = ['factory' => Plugin\Settings\Settings::class, 'factory_method' => function () use ($container, $parameters): Plugin\Settings\Settings { - $settings = new Plugin\Settings\Settings($container->getByClass(Plugin\Settings\Repository\SettingsDatabase::class)); - $settings->setDefaultSettings($parameters['default_settings']); - - return $settings; - }]; - $container['settings.synchronizer'] = Plugin\Settings\Synchronizer::class; - - // User - $container['user.sign'] = ['factory' => Plugin\User\Sign::class, 'factory_method' => function () use ($container, $parameters): Plugin\User\Sign { - $sign = new Plugin\User\Sign( - $container->getByClass(Plugin\Settings\Settings::class), - $container->getByClass(Plugin\IO\Connection::class), - $container->getByClass(Plugin\IO\Url::class), - $container->getByClass(Eshop\Configuration::class), - $container->getByClass(Plugin\Localization\Language::class), - $container->getByClass(Plugin\Debug\Logger::class), - ); - $sign->setDefaultParameters(['referer_id' => $parameters['referer_id'] ?? null]); - - return $sign; - }]; - - return $container; - } + use Plugin\Strict; + use Plugin\DI\FactoryStatic; + + /** + * @param array $parameters + */ + protected static function createContainer(array $parameters = []): Plugin\DI\Container + { + /** + * @var SymfonyContainer $symfony_di + */ + ['symfony_di' => $symfony_di] = $parameters; + + /** + * @var LegacyContext $legacy_context + */ + $legacy_context = $symfony_di->get('prestashop.adapter.legacy.context'); + + $container = new Plugin\DI\Container($parameters['mode'] ?? 'strict'); + + $container['prestashop.adapter.shop.context'] = Context::class; + $container['prestashop.adapter.order.state'] = OrderStateDataProvider::class; + $container['prestashop.adapter.order.return_state'] = OrderReturnStateDataProvider::class; + $container['prestashop.adapter.shop.base_url'] = ['factory' => BaseUrlProvider::class, 'factory_method' => fn() => new BaseUrlProvider($legacy_context->getContext()->link)]; + $container['prestashop.adapter.employee.context'] = ['factory' => ContextEmployeeProvider::class, 'factory_method' => fn() => new ContextEmployeeProvider($legacy_context->getContext()->employee)]; + + // Database + $container['database.connection'] = ['factory' => Connection::class, 'parameters' => ['db' => $symfony_di->get('doctrine.dbal.default_connection')]]; + + // Debug + $container['debug.repository.logger'] = ['factory' => Plugin\Debug\Repository\LoggerSettings::class, 'factory_method' => function () use ($container, $parameters): Plugin\Debug\Repository\LoggerSettings { + $logger = new Plugin\Debug\Repository\LoggerSettings($container->getByClass(Plugin\Settings\Settings::class)); + $logger->setup(is_int($parameters['logger_limit'] ?? null) ? $parameters['logger_limit'] : 100); + + return $logger; + }]; + $container['debug.logger'] = ['factory' => Plugin\Debug\Logger::class, 'parameters' => ['platform_version' => $parameters['platform_version'], 'module_version' => $parameters['module_version']]]; + $container['debug.requirements'] = Plugin\Debug\Requirements::class; + + // Ajax + $container['ajax.authenticate'] = Ajax\Authenticate::class; + $container['ajax.plugin_settings'] = Ajax\PluginSettingsChange::class; + + // Eshop + $container['eshop.configuration'] = ['factory' => Eshop\Configuration::class, 'factory_method' => fn () => new Eshop\Configuration( + $parameters['module_version'], + $container->getByClass(BaseUrlProvider::class), + $container->getByClass(Context::class) + )]; + $container['eshop.synchronizer'] = Plugin\Eshop\EshopSynchronizer::class; + $container['eshop.order_status'] = ['factory' => Eshop\OrderStatus::class, 'factory_method' => fn () => new Eshop\OrderStatus( + $container->getByClass(OrderStateDataProvider::class), + $container->getByClass(ContextEmployeeProvider::class) + )]; + $container['eshop.return_status'] = ['factory' => Eshop\ReturnStatus::class, 'factory_method' => fn () => new Eshop\ReturnStatus( + $container->getByClass(OrderReturnStateDataProvider::class), + $container->getByClass(ContextEmployeeProvider::class) + )]; + $container['eshop.language'] = Eshop\Language::class; + $container['eshop.multistore'] = ['factory' => Eshop\MultiStore::class, 'factory_method' => fn () => new Eshop\MultiStore( + $container->getByClass(Context::class) + )]; + + // Event loaders + $container['event.loader.extension'] = ['factory' => Event\Loader\Extension::class, 'auto_wiring' => false]; + $container['event.loader.shop'] = ['factory' => Event\Loader\Shop::class, 'auto_wiring' => false]; + $container['event.loader.order'] = ['factory' => Event\Loader\Order::class, 'auto_wiring' => false]; + $container['event.loader.order_status'] = ['factory' => Event\Loader\OrderStatus::class, 'auto_wiring' => false]; + $container['event.loader.customer'] = ['factory' => Event\Loader\Customer::class, 'auto_wiring' => false]; + $container['event.loader.product'] = ['factory' => Event\Loader\Product::class, 'auto_wiring' => false]; + $container['event.loader.post'] = ['factory' => Event\Loader\Post::class, 'auto_wiring' => false]; + $container['event.loader'] = ['factory' => Plugin\Event\Loader::class, 'factory_method' => fn () => new Plugin\Event\Loader([ + $container->getByClass(Event\Loader\Order::class), + $container->getByClass(Event\Loader\OrderStatus::class), + $container->getByClass(Event\Loader\Customer::class), + $container->getByClass(Event\Loader\Shop::class), + $container->getByClass(Event\Loader\Product::class), + $container->getByClass(Event\Loader\Post::class), + $container->getByClass(Event\Loader\Extension::class), + ])]; + $container['event.dispatcher'] = Dispatcher::class; + + if (in_array($parameters['dispatcher'] ?? null, [Dispatcher::Asset, Dispatcher::Cron, Dispatcher::Direct], true)) { + Dispatcher::$default_dispatcher = $parameters['dispatcher']; + } + + // Event + $container['event.hook'] = ['factory' => Plugin\Event\Hook::class, 'parameters' => ['version' => $parameters['api_version'] ?? '1.0']]; + $container['event.asynchronous.repository'] = Plugin\Event\Repository\AsynchronousDatabase::class; + $container['event.asynchronous'] = Plugin\Event\Asynchronous::class; + + // IO + $container['io.connection.factory'] = ['factory' => Plugin\IO\ConnectionFactory::class, 'factory_method' => function () use ($container): Plugin\IO\ConnectionFactory { + $configuration = $container->getByClass(Eshop\Configuration::class); + + return new Plugin\IO\ConnectionFactory($configuration->url(), $configuration->product(), $container->getByClass(Plugin\Settings\Settings::class)); + }]; + $container['io.connection'] = ['factory' => Plugin\IO\Connection::class, 'factory_method' => fn () => $container->getByClass(Plugin\IO\ConnectionFactory::class)->create()]; + $container['io.url'] = ['factory' => Plugin\IO\Url::class, 'parameters' => ['url' => $parameters['gate_url'] ?? 'https://portal.bulkgate.com']]; + + // Localization + $iso = $container->getByClass(Eshop\Language::class)->get($legacy_context->getLanguage()->getId()); // pozor! bezi v ruznych kontextech FO a BO + $container['localization.language'] = ['factory' => Plugin\Localization\LanguageSettings::class, 'parameters' => ['iso' => $iso]]; + $container['localization.translator'] = Plugin\Localization\TranslatorSettings::class; + $container['localization.formatter'] = extension_loaded('intl') ? ['factory' => Plugin\Localization\FormatterIntl::class, 'factory_method' => fn () => new Plugin\Localization\FormatterIntl($iso)] : Plugin\Localization\FormatterBasic::class; + + // Settings + $container['settings.repository.database'] = Plugin\Settings\Repository\SettingsDatabase::class; + $container['settings.repository.synchronizer'] = Plugin\Settings\Repository\SynchronizationDatabase::class; + $container['settings.settings'] = ['factory' => Plugin\Settings\Settings::class, 'factory_method' => function () use ($container, $parameters): Plugin\Settings\Settings { + $settings = new Plugin\Settings\Settings($container->getByClass(Plugin\Settings\Repository\SettingsDatabase::class)); + $settings->setDefaultSettings($parameters['default_settings']); + + return $settings; + }]; + $container['settings.synchronizer'] = Plugin\Settings\Synchronizer::class; + + // User + $container['user.sign'] = ['factory' => Plugin\User\Sign::class, 'factory_method' => function () use ($container, $parameters): Plugin\User\Sign { + $sign = new Plugin\User\Sign( + $container->getByClass(Plugin\Settings\Settings::class), + $container->getByClass(Plugin\IO\Connection::class), + $container->getByClass(Plugin\IO\Url::class), + $container->getByClass(Eshop\Configuration::class), + $container->getByClass(Plugin\Localization\Language::class), + $container->getByClass(Plugin\Debug\Logger::class), + ); + $sign->setDefaultParameters(['referer_id' => $parameters['referer_id'] ?? null]); + + return $sign; + }]; + + return $container; + } } diff --git a/src/Eshop/Configuration.php b/src/Eshop/Configuration.php index a7323f3..d000444 100644 --- a/src/Eshop/Configuration.php +++ b/src/Eshop/Configuration.php @@ -6,6 +6,7 @@ use BulkGate\Plugin\Eshop; use BulkGate\Plugin\Strict; +use PrestaShop\PrestaShop\Core\Shop\Url\UrlProviderInterface; use PrestaShop\PrestaShop\Adapter\Shop; /** @@ -23,7 +24,7 @@ class Configuration implements Eshop\Configuration private string $site_name; - public function __construct(string $version_number, Shop\Url\BaseUrlProvider $url_provider, Shop\Context $shop) + public function __construct(string $version_number, UrlProviderInterface $url_provider, Shop\Context $shop) { $this->version_number = $version_number; $this->site_url = $url_provider->getUrl(); diff --git a/src/Eshop/OrderStatus.php b/src/Eshop/OrderStatus.php index 8340a71..fd17f42 100644 --- a/src/Eshop/OrderStatus.php +++ b/src/Eshop/OrderStatus.php @@ -6,8 +6,8 @@ use BulkGate\Plugin\Eshop; use BulkGate\Plugin\Strict; -use PrestaShop\PrestaShop\Adapter\Employee\ContextEmployeeProvider; -use PrestaShop\PrestaShop\Adapter\OrderState\OrderStateDataProvider; +use PrestaShop\PrestaShop\Core\Employee\ContextEmployeeProviderInterface; +use PrestaShop\PrestaShop\Core\Order\OrderStateDataProviderInterface; /** * @author Martin Kreizl 2025 TOPefekt s.r.o. @@ -18,11 +18,11 @@ class OrderStatus implements Eshop\OrderStatus { use Strict; - private OrderStateDataProvider $order_state; + private OrderStateDataProviderInterface $order_state; - private ContextEmployeeProvider $employee; + private ContextEmployeeProviderInterface $employee; - public function __construct(OrderStateDataProvider $order_state, ContextEmployeeProvider $employee) + public function __construct(OrderStateDataProviderInterface $order_state, ContextEmployeeProviderInterface $employee) { $this->order_state = $order_state; $this->employee = $employee; diff --git a/src/Eshop/ReturnStatus.php b/src/Eshop/ReturnStatus.php index 03f5b89..ed333b4 100644 --- a/src/Eshop/ReturnStatus.php +++ b/src/Eshop/ReturnStatus.php @@ -6,8 +6,8 @@ use BulkGate\Plugin\Eshop; use BulkGate\Plugin\Strict; -use PrestaShop\PrestaShop\Adapter\Employee\ContextEmployeeProvider; -use PrestaShop\PrestaShop\Adapter\OrderReturnState\OrderReturnStateDataProvider; +use PrestaShop\PrestaShop\Core\Employee\ContextEmployeeProviderInterface; +use PrestaShop\PrestaShop\Core\Order\OrderReturnStateDataProviderInterface; /** * @author Martin Kreizl 2025 TOPefekt s.r.o. @@ -18,11 +18,11 @@ class ReturnStatus implements Eshop\ReturnStatus { use Strict; - private OrderReturnStateDataProvider $order_state; + private OrderReturnStateDataProviderInterface $order_state; - private ContextEmployeeProvider $employee; + private ContextEmployeeProviderInterface $employee; - public function __construct(OrderReturnStateDataProvider $order_state, ContextEmployeeProvider $employee) + public function __construct(OrderReturnStateDataProviderInterface $order_state, ContextEmployeeProviderInterface $employee) { $this->order_state = $order_state; $this->employee = $employee; diff --git a/tests/Eshop/ConfigurationTest.phpt b/tests/Eshop/ConfigurationTest.phpt index 403e524..96bc665 100644 --- a/tests/Eshop/ConfigurationTest.phpt +++ b/tests/Eshop/ConfigurationTest.phpt @@ -7,7 +7,8 @@ require_once __DIR__ . '/../bootstrap.php'; use Mockery; use Tester\{Assert, TestCase}; use BulkGate\PrestaShop\Eshop\Configuration; -use PrestaShop\PrestaShop\Adapter\{Shop\Context, Shop\Url\BaseUrlProvider}; +use PrestaShop\PrestaShop\Core\Shop\Url\UrlProviderInterface; +use PrestaShop\PrestaShop\Adapter\{Shop\Context}; /** * @author Lukáš Piják 2025 TOPefekt s.r.o. @@ -18,7 +19,7 @@ class ConfigurationTest extends TestCase { public function testConfiguration(): void { - $url_provider = Mockery::mock(BaseUrlProvider::class); + $url_provider = Mockery::mock(UrlProviderInterface::class); $shop = Mockery::mock(Context::class); $url_provider->shouldReceive('getUrl')->once()->andReturn('https://eshop.cz/'); $shop->shouldReceive('getShopName')->once()->andReturn('Můj Eshop'); diff --git a/tests/Eshop/OrderStatusTest.phpt b/tests/Eshop/OrderStatusTest.phpt index 812b922..535c2b9 100644 --- a/tests/Eshop/OrderStatusTest.phpt +++ b/tests/Eshop/OrderStatusTest.phpt @@ -7,7 +7,7 @@ require_once __DIR__ . '/../bootstrap.php'; use Mockery; use Tester\{Assert, TestCase}; use BulkGate\PrestaShop\Eshop\OrderStatus; -use PrestaShop\PrestaShop\Adapter\{OrderState\OrderStateDataProvider, Employee\ContextEmployeeProvider}; +use PrestaShop\PrestaShop\Core\{Employee\ContextEmployeeProviderInterface, Order\OrderStateDataProviderInterface}; /** * @author Lukáš Piják 2025 TOPefekt s.r.o. @@ -18,7 +18,7 @@ class OrderStatusTest extends TestCase { public function testLoad(): void { - $orderStatus = new OrderStatus($order_state = Mockery::mock(OrderStateDataProvider::class), $employee = Mockery::mock(ContextEmployeeProvider::class)); + $orderStatus = new OrderStatus($order_state = Mockery::mock(OrderStateDataProviderInterface::class), $employee = Mockery::mock(ContextEmployeeProviderInterface::class)); $employee->shouldReceive('getLanguageId')->once()->andReturn(8); $order_state->shouldReceive('getOrderStates')->with(8)->once()->andReturn([ ['id_order_state' => 1, 'name' => 'Nová objednávka'], diff --git a/tests/Eshop/ReturnStatusTest.phpt b/tests/Eshop/ReturnStatusTest.phpt index ec37a5d..ee12555 100644 --- a/tests/Eshop/ReturnStatusTest.phpt +++ b/tests/Eshop/ReturnStatusTest.phpt @@ -7,7 +7,7 @@ require_once __DIR__ . '/../bootstrap.php'; use Mockery; use Tester\{Assert, TestCase}; use BulkGate\PrestaShop\Eshop\ReturnStatus; -use PrestaShop\PrestaShop\Adapter\{OrderReturnState\OrderReturnStateDataProvider, Employee\ContextEmployeeProvider}; +use PrestaShop\PrestaShop\Core\{Employee\ContextEmployeeProviderInterface, Order\OrderReturnStateDataProviderInterface}; /** * @author Lukáš Piják 2025 TOPefekt s.r.o. @@ -18,7 +18,7 @@ class ReturnStatusTest extends TestCase { public function testLoad(): void { - $returnStatus = new ReturnStatus($return_state = Mockery::mock(OrderReturnStateDataProvider::class), $employee = Mockery::mock(ContextEmployeeProvider::class)); + $returnStatus = new ReturnStatus($return_state = Mockery::mock(OrderReturnStateDataProviderInterface::class), $employee = Mockery::mock(ContextEmployeeProviderInterface::class)); $employee->shouldReceive('getLanguageId')->once()->andReturn(8); $return_state->shouldReceive('getOrderReturnStates')->with(8)->once()->andReturn([ ['id_order_return_state' => 1, 'name' => 'Čeká na schválení'], diff --git a/views/templates/admin/index.html.twig b/views/templates/admin/index.html.twig index c350f8d..84a61d3 100644 --- a/views/templates/admin/index.html.twig +++ b/views/templates/admin/index.html.twig @@ -161,6 +161,8 @@ {% endblock %} {% block stylesheets %} + {{ parent() }} +