From c7632a4526f0059183d1e6cfacfd63c75968e45f Mon Sep 17 00:00:00 2001 From: Tomas J <72136043+tomjas1997@users.noreply.github.com> Date: Fri, 16 Jun 2023 16:24:09 +0300 Subject: [PATCH 01/20] DGS-238 shipping tab improvements (#104) * DGS-238 shipping tab improvements * Adding auto indexes * Unrequired change removal * Automatic license addition applying --------- Co-authored-by: tomjas1997 --- config/config.yml | 1 - config/factory.yml | 5 - config/repository.yml | 10 + config/service.yml | 39 ++- ...minDPDBalticsAddressTemplateController.php | 3 +- ...nDPDBalticsCollectionRequestController.php | 5 +- ...dminDPDBalticsCourierRequestController.php | 5 +- .../AdminDPDBalticsImportExportController.php | 7 +- .../admin/AdminDPDBalticsModuleController.php | 4 +- .../AdminDPDBalticsPriceRulesController.php | 3 +- ...DBalticsProductsAvailabilityController.php | 5 +- ...dminDPDBalticsRequestSupportController.php | 3 +- .../AdminDPDBalticsSettingsController.php | 3 +- ...inDPDBalticsShipmentSettingsController.php | 3 +- .../admin/AdminDPDBalticsZonesController.php | 5 +- dpdbaltics.php | 96 ++++---- src/Controller/AbstractAdminController.php | 9 +- .../Shared/Repository/LanguageRepository.php | 40 ++++ .../LanguageRepositoryInterface.php | 33 +++ src/Core/Shared/Repository/TabRepository.php | 31 +++ .../Repository/TabRepositoryInterface.php | 27 +++ src/Core/Shared/Repository/index.php | 30 +++ src/Core/Shared/index.php | 30 +++ src/Core/index.php | 30 +++ src/Factory/TabFactory.php | 77 ------ src/Infrastructure/Adapter/ModuleFactory.php | 16 ++ src/Infrastructure/Adapter/index.php | 30 +++ .../Exception/CouldNotInstallModule.php | 39 +++ .../Exception/CouldNotUninstallModule.php | 39 +++ .../Bootstrap/Exception/index.php | 28 +++ .../Bootstrap/Install/Installer.php | 32 +++ .../Bootstrap/Install/InstallerInterface.php | 31 +++ .../Bootstrap/Install/ModuleTabInstaller.php | 106 +++++++++ .../Bootstrap/Install/index.php | 30 +++ src/Infrastructure/Bootstrap/ModuleTabs.php | 222 ++++++++++++++++++ .../Uninstall/ModuleTabUninstaller.php | 71 ++++++ .../Bootstrap/Uninstall/Uninstaller.php | 50 ++++ .../Uninstall/UninstallerInterface.php | 31 +++ .../Bootstrap/Uninstall/index.php | 30 +++ src/Infrastructure/Bootstrap/index.php | 30 +++ src/Infrastructure/Exception/DpdException.php | 65 +++++ .../Exception/ExceptionCode.php | 32 +++ src/Infrastructure/Exception/index.php | 30 +++ .../Repository/CollectionRepository.php | 57 +++++ .../ReadOnlyCollectionRepositoryInterface.php | 46 ++++ src/Infrastructure/Repository/index.php | 30 +++ .../Utility/ExceptionUtility.php | 41 ++++ src/Infrastructure/Utility/VersionUtility.php | 49 ++++ src/Infrastructure/Utility/index.php | 30 +++ src/Infrastructure/index.php | 30 +++ src/Install/Installer.php | 118 ++-------- src/OnBoard/OnBoardSteps/StepImport1.php | 3 +- src/OnBoard/OnBoardSteps/StepImport2.php | 3 +- .../OnBoardSteps/StepManualPriceRules0.php | 3 +- .../OnBoardSteps/StepManualPriceRules1.php | 3 +- .../OnBoardSteps/StepManualPriceRules2.php | 3 +- .../OnBoardSteps/StepManualPriceRules3.php | 3 +- .../OnBoardSteps/StepManualPriceRules4.php | 3 +- .../OnBoardSteps/StepManualPriceRules5.php | 3 +- .../OnBoardSteps/StepManualPriceRules6.php | 3 +- .../OnBoardSteps/StepManualPriceRules7.php | 3 +- .../OnBoardSteps/StepManualPriceRules8.php | 3 +- .../OnBoardSteps/StepManualProducts0.php | 3 +- .../OnBoardSteps/StepManualProducts1.php | 3 +- .../OnBoardSteps/StepManualProducts2.php | 3 +- .../OnBoardSteps/StepManualProducts3.php | 3 +- .../OnBoardSteps/StepManualProducts4.php | 3 +- .../OnBoardSteps/StepManualProducts5.php | 3 +- .../OnBoardSteps/StepManualProducts5Shop.php | 3 +- .../OnBoardSteps/StepManualProducts6.php | 3 +- .../OnBoardSteps/StepManualProducts7.php | 3 +- .../OnBoardSteps/StepManualProducts8.php | 3 +- .../OnBoardSteps/StepManualProducts9.php | 3 +- src/OnBoard/OnBoardSteps/StepManualZones0.php | 3 +- src/OnBoard/OnBoardSteps/StepManualZones1.php | 3 +- src/OnBoard/OnBoardSteps/StepManualZones2.php | 3 +- src/OnBoard/OnBoardSteps/StepManualZones3.php | 3 +- src/OnBoard/OnBoardSteps/StepManualZones4.php | 3 +- src/OnBoard/OnBoardSteps/StepManualZones5.php | 3 +- src/OnBoard/OnBoardSteps/StepManualZones6.php | 3 +- src/Provider/ImportExportURLProvider.php | 3 +- src/Service/TabService.php | 215 ----------------- src/Util/FileDownload.php | 2 +- upgrade/Upgrade-1.1.1.php | 40 ++-- upgrade/Upgrade-1.1.2.php | 1 - upgrade/Upgrade-1.1.5.php | 1 - upgrade/Upgrade-3.2.16.php | 41 ++++ 87 files changed, 1673 insertions(+), 534 deletions(-) create mode 100644 src/Core/Shared/Repository/LanguageRepository.php create mode 100644 src/Core/Shared/Repository/LanguageRepositoryInterface.php create mode 100644 src/Core/Shared/Repository/TabRepository.php create mode 100644 src/Core/Shared/Repository/TabRepositoryInterface.php create mode 100644 src/Core/Shared/Repository/index.php create mode 100644 src/Core/Shared/index.php create mode 100644 src/Core/index.php delete mode 100644 src/Factory/TabFactory.php create mode 100644 src/Infrastructure/Adapter/ModuleFactory.php create mode 100644 src/Infrastructure/Adapter/index.php create mode 100644 src/Infrastructure/Bootstrap/Exception/CouldNotInstallModule.php create mode 100644 src/Infrastructure/Bootstrap/Exception/CouldNotUninstallModule.php create mode 100644 src/Infrastructure/Bootstrap/Exception/index.php create mode 100644 src/Infrastructure/Bootstrap/Install/Installer.php create mode 100644 src/Infrastructure/Bootstrap/Install/InstallerInterface.php create mode 100644 src/Infrastructure/Bootstrap/Install/ModuleTabInstaller.php create mode 100644 src/Infrastructure/Bootstrap/Install/index.php create mode 100644 src/Infrastructure/Bootstrap/ModuleTabs.php create mode 100644 src/Infrastructure/Bootstrap/Uninstall/ModuleTabUninstaller.php create mode 100644 src/Infrastructure/Bootstrap/Uninstall/Uninstaller.php create mode 100644 src/Infrastructure/Bootstrap/Uninstall/UninstallerInterface.php create mode 100644 src/Infrastructure/Bootstrap/Uninstall/index.php create mode 100644 src/Infrastructure/Bootstrap/index.php create mode 100644 src/Infrastructure/Exception/DpdException.php create mode 100644 src/Infrastructure/Exception/ExceptionCode.php create mode 100644 src/Infrastructure/Exception/index.php create mode 100644 src/Infrastructure/Repository/CollectionRepository.php create mode 100644 src/Infrastructure/Repository/ReadOnlyCollectionRepositoryInterface.php create mode 100644 src/Infrastructure/Repository/index.php create mode 100644 src/Infrastructure/Utility/ExceptionUtility.php create mode 100644 src/Infrastructure/Utility/VersionUtility.php create mode 100644 src/Infrastructure/Utility/index.php create mode 100644 src/Infrastructure/index.php delete mode 100644 src/Service/TabService.php create mode 100644 upgrade/Upgrade-3.2.16.php diff --git a/config/config.yml b/config/config.yml index b037a5ca..4dd619ef 100644 --- a/config/config.yml +++ b/config/config.yml @@ -63,7 +63,6 @@ services: class: 'Invertus\dpdBaltics\Install\Installer' arguments: - '@dpdbaltics' - - '@invertus.dpdbaltics.factory.tab_factory' - '@invertus.dpdbaltics.service.carrier.create_carrier_service' - '@invertus.dpdbaltics.repository.carrier_repository' diff --git a/config/factory.yml b/config/factory.yml index c1e33906..94132248 100644 --- a/config/factory.yml +++ b/config/factory.yml @@ -8,11 +8,6 @@ services: invertus.dpdbaltics_factory.context_factory: class: 'Invertus\dpdBaltics\Factory\ContextFactory' - invertus.dpdbaltics.factory.tab_factory: - class: 'Invertus\dpdBaltics\Factory\TabFactory' - arguments: - - '@invertus.dpdbaltics.service.tab_service' - invertus.dpdbaltics.factory.apiparams_factory: class: 'Invertus\dpdBaltics\Factory\APIParamsFactory' arguments: diff --git a/config/repository.yml b/config/repository.yml index 2b2924cd..d2072671 100644 --- a/config/repository.yml +++ b/config/repository.yml @@ -76,3 +76,13 @@ services: invertus.dpdbaltics.repository.order_delivery_time_repository: class: 'Invertus\dpdBaltics\Repository\OrderDeliveryTimeRepository' + + Invertus\dpdBaltics\Core\Shared\Repository\LanguageRepository: + class: 'Invertus\dpdBaltics\Core\Shared\Repository\LanguageRepository' + + Invertus\dpdBaltics\Core\Shared\Repository\LanguageRepositoryInterface: '@Invertus\dpdBaltics\Core\Shared\Repository\LanguageRepository' + + Invertus\dpdBaltics\Core\Shared\Repository\TabRepository: + class: 'Invertus\dpdBaltics\Core\Shared\Repository\TabRepository' + + Invertus\dpdBaltics\Core\Shared\Repository\TabRepositoryInterface: '@Invertus\dpdBaltics\Core\Shared\Repository\TabRepository' \ No newline at end of file diff --git a/config/service.yml b/config/service.yml index 625d7171..e7a9c2ee 100644 --- a/config/service.yml +++ b/config/service.yml @@ -75,11 +75,6 @@ services: - '@invertus.dpdbaltics.service.price_rule_service' - '@invertus.dpdbaltics.repository.price_rule_repository' - invertus.dpdbaltics.service.tab_service: - class: 'Invertus\dpdBaltics\Service\TabService' - arguments: - - '@dpdbaltics' - invertus.dpdbaltics.service.zone.delete_zone_service: class: 'Invertus\dpdBaltics\Service\Zone\DeleteZoneService' arguments: @@ -293,3 +288,37 @@ services: arguments: - '@invertus.dpdbaltics.service.api.label_api_service' - '@invertus.dpdbaltics.service.shipment_service' + + Invertus\dpdBaltics\Infrastructure\Adapter\ModuleFactory: + class: 'Invertus\dpdBaltics\Infrastructure\Adapter\ModuleFactory' + + Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs: + class: 'Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs' + arguments: + - '@Invertus\dpdBaltics\Infrastructure\Adapter\ModuleFactory' + + Invertus\dpdBaltics\Infrastructure\Bootstrap\Install\ModuleTabInstaller: + class: 'Invertus\dpdBaltics\Infrastructure\Bootstrap\Install\ModuleTabInstaller' + arguments: + - '@Invertus\dpdBaltics\Infrastructure\Adapter\ModuleFactory' + - '@Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs' + - '@Invertus\dpdBaltics\Core\Shared\Repository\TabRepositoryInterface' + - '@Invertus\dpdBaltics\Core\Shared\Repository\LanguageRepositoryInterface' + + Invertus\dpdBaltics\Infrastructure\Bootstrap\Install\Installer: + class: 'Invertus\dpdBaltics\Infrastructure\Bootstrap\Install\Installer' + arguments: + - '@Invertus\dpdBaltics\Infrastructure\Bootstrap\Install\ModuleTabInstaller' + - '@invertus.dpdbaltics.install.installer' + + Invertus\dpdBaltics\Infrastructure\Bootstrap\Uninstall\ModuleTabUninstaller: + class: 'Invertus\dpdBaltics\Infrastructure\Bootstrap\Uninstall\ModuleTabUninstaller' + arguments: + - '@Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs' + - '@Invertus\dpdBaltics\Core\Shared\Repository\TabRepositoryInterface' + + Invertus\dpdBaltics\Infrastructure\Bootstrap\Uninstall\Uninstaller: + class: 'Invertus\dpdBaltics\Infrastructure\Bootstrap\Uninstall\Uninstaller' + arguments: + - '@Invertus\dpdBaltics\Infrastructure\Bootstrap\Uninstall\ModuleTabUninstaller' + - '@invertus.dpdbaltics.install.installer' \ No newline at end of file diff --git a/controllers/admin/AdminDPDBalticsAddressTemplateController.php b/controllers/admin/AdminDPDBalticsAddressTemplateController.php index da5ec663..de9d2501 100644 --- a/controllers/admin/AdminDPDBalticsAddressTemplateController.php +++ b/controllers/admin/AdminDPDBalticsAddressTemplateController.php @@ -23,6 +23,7 @@ use Invertus\dpdBaltics\Builder\Template\SearchBoxBuilder; use Invertus\dpdBaltics\Config\Config; use Invertus\dpdBaltics\Controller\AbstractAdminController; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\Repository\AddressRepository; use Invertus\dpdBaltics\Repository\PhonePrefixRepository; use Invertus\dpdBaltics\Repository\ShopRepository; @@ -101,7 +102,7 @@ public function setMedia($isNewTheme = false) Media::addJsDef([ 'dpdAjaxUrl' => - $this->context->link->getAdminLink(DPDBaltics::ADMIN_AJAX_CONTROLLER), + $this->context->link->getAdminLink(ModuleTabs::ADMIN_AJAX_CONTROLLER), 'inputWarningMessage' => $this->l('Please fill all required fields') ]); } diff --git a/controllers/admin/AdminDPDBalticsCollectionRequestController.php b/controllers/admin/AdminDPDBalticsCollectionRequestController.php index dd70e5b1..32cad447 100644 --- a/controllers/admin/AdminDPDBalticsCollectionRequestController.php +++ b/controllers/admin/AdminDPDBalticsCollectionRequestController.php @@ -24,6 +24,7 @@ use Invertus\dpdBaltics\Controller\AbstractAdminController; use Invertus\dpdBaltics\Converter\FormDataConverter; use Invertus\dpdBaltics\DTO\CollectionRequestData; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\Repository\AddressRepository; use Invertus\dpdBaltics\Repository\CollectionRequestRepository; use Invertus\dpdBaltics\Repository\PhonePrefixRepository; @@ -344,7 +345,7 @@ public function setMedia($isNewTheme = false) Media::addJsDef([ 'dpdAjaxUrl' => - $this->context->link->getAdminLink(DPDBaltics::ADMIN_AJAX_CONTROLLER), + $this->context->link->getAdminLink(ModuleTabs::ADMIN_AJAX_CONTROLLER), ]); } @@ -405,7 +406,7 @@ public function postProcess() public function displayViewCollectionRequestLink($token, $idCollectionRequest) { $collectionRequestUrl = - $this->context->link->getAdminLink(DPDBaltics::ADMIN_COLLECTION_REQUEST_CONTROLLER, false); + $this->context->link->getAdminLink(ModuleTabs::ADMIN_COLLECTION_REQUEST_CONTROLLER, false); $collectionRequestUrl .= '&id_dpd_collection_request=' . $idCollectionRequest . '&updatedpd_collection_request&token=' . $token; diff --git a/controllers/admin/AdminDPDBalticsCourierRequestController.php b/controllers/admin/AdminDPDBalticsCourierRequestController.php index a5a56f19..9d527ccf 100644 --- a/controllers/admin/AdminDPDBalticsCourierRequestController.php +++ b/controllers/admin/AdminDPDBalticsCourierRequestController.php @@ -24,6 +24,7 @@ use Invertus\dpdBaltics\Controller\AbstractAdminController; use Invertus\dpdBaltics\Converter\FormDataConverter; use Invertus\dpdBaltics\DTO\CourierRequestData; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\Repository\AddressRepository; use Invertus\dpdBaltics\Repository\CourierRequestRepository; use Invertus\dpdBaltics\Repository\PhonePrefixRepository; @@ -303,7 +304,7 @@ public function setMedia($isNewTheme = false) Media::addJsDef([ 'dpdAjaxUrl' => - $this->context->link->getAdminLink(DPDBaltics::ADMIN_AJAX_CONTROLLER), + $this->context->link->getAdminLink(ModuleTabs::ADMIN_AJAX_CONTROLLER), ]); } @@ -379,7 +380,7 @@ public function postProcess() public function displayViewCourierRequestLink($token, $idCourierRequest) { $courierRequestUrl = - $this->context->link->getAdminLink(DPDBaltics::ADMIN_COURIER_REQUEST_CONTROLLER, false); + $this->context->link->getAdminLink(ModuleTabs::ADMIN_COURIER_REQUEST_CONTROLLER, false); $courierRequestUrl .= '&id_dpd_courier_request=' . $idCourierRequest . '&updatedpd_courier_request&token=' . $token; diff --git a/controllers/admin/AdminDPDBalticsImportExportController.php b/controllers/admin/AdminDPDBalticsImportExportController.php index 072bea62..660734ee 100644 --- a/controllers/admin/AdminDPDBalticsImportExportController.php +++ b/controllers/admin/AdminDPDBalticsImportExportController.php @@ -24,6 +24,7 @@ use Invertus\dpdBaltics\Config\Config; use Invertus\dpdBaltics\Controller\AbstractAdminController; use Invertus\dpdBaltics\Exception\ImportException; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\Provider\ImportExportOptionsProvider; use Invertus\dpdBaltics\Service\DPDFlashMessageService; use Invertus\dpdBaltics\Service\Export\ExportProvider; @@ -57,7 +58,7 @@ public function postProcess() if (Tools::isSubmit('submitProcessImportZones')) { Media::addJsDef([ 'dpdAjaxUrl' => - $this->context->link->getAdminLink(DPDBaltics::ADMIN_AJAX_CONTROLLER), + $this->context->link->getAdminLink(ModuleTabs::ADMIN_AJAX_CONTROLLER), 'successMessage' => $this->module->l('Zones successfully imported'), 'failMessage' => $this->module->l('Zones import failed') ]); @@ -68,7 +69,7 @@ public function postProcess() if (Tools::isSubmit('submitProcessImportParcels')) { Media::addJsDef([ 'dpdAjaxUrl' => - $this->context->link->getAdminLink(DPDBaltics::ADMIN_AJAX_CONTROLLER), + $this->context->link->getAdminLink(ModuleTabs::ADMIN_AJAX_CONTROLLER), 'successMessage' => $this->module->l('Parcels successfully updated'), 'failMessage' => $this->module->l('Parcels update failed'), 'countryId' => Tools::getValue('DPD_PARCEL_IMPORT_COUNTRY_SELECTOR') @@ -391,7 +392,7 @@ private function postProcessImport($importOption, $deleteOnImport, $importFile = $flashMessageService = $this->module->getModuleContainer('invertus.dpdbaltics.service.dpdflash_message_service'); $flashMessageService->addFlash('success', $this->confirmations); - Tools::redirectAdmin($this->context->link->getAdminLink(DPDBaltics::ADMIN_IMPORT_EXPORT_CONTROLLER)); + Tools::redirectAdmin($this->context->link->getAdminLink(ModuleTabs::ADMIN_IMPORT_EXPORT_CONTROLLER)); } return; diff --git a/controllers/admin/AdminDPDBalticsModuleController.php b/controllers/admin/AdminDPDBalticsModuleController.php index d6c5e6df..07a5e9cd 100644 --- a/controllers/admin/AdminDPDBalticsModuleController.php +++ b/controllers/admin/AdminDPDBalticsModuleController.php @@ -19,13 +19,15 @@ */ +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; + require_once dirname(__DIR__).'/../vendor/autoload.php'; class AdminDPDBalticsModuleController extends ModuleAdminController { public function postProcess() { - Tools::redirectAdmin($this->context->link->getAdminLink(DPDBaltics::ADMIN_SETTINGS_CONTROLLER)); + Tools::redirectAdmin($this->context->link->getAdminLink(ModuleTabs::ADMIN_SETTINGS_CONTROLLER)); return parent::postProcess(); // TODO: Change the autogenerated stub } } diff --git a/controllers/admin/AdminDPDBalticsPriceRulesController.php b/controllers/admin/AdminDPDBalticsPriceRulesController.php index ea0558fb..25fc48b9 100644 --- a/controllers/admin/AdminDPDBalticsPriceRulesController.php +++ b/controllers/admin/AdminDPDBalticsPriceRulesController.php @@ -13,6 +13,7 @@ use Invertus\dpdBaltics\Builder\Template\SearchBoxBuilder; use Invertus\dpdBaltics\Config\Config; use Invertus\dpdBaltics\Controller\AbstractAdminController; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\Repository\DPDZoneRepository; use Invertus\dpdBaltics\Repository\ShopRepository; use Invertus\dpdBaltics\Service\DPDFlashMessageService; @@ -340,7 +341,7 @@ private function getFieldFormVars() if (empty($priceRuleZones)) { $this->fields_value['search_block'] = $this->getMessageWithLink( 'warning', - $this->context->link->getAdminLink(DPDBaltics::ADMIN_ZONES_CONTROLLER) . + $this->context->link->getAdminLink(ModuleTabs::ADMIN_ZONES_CONTROLLER) . '&add' . DPDZone::$definition['table'], $this->l('There are no zones to add. '), $this->l(' to add more zones.') diff --git a/controllers/admin/AdminDPDBalticsProductsAvailabilityController.php b/controllers/admin/AdminDPDBalticsProductsAvailabilityController.php index 9a65a582..706a61b4 100644 --- a/controllers/admin/AdminDPDBalticsProductsAvailabilityController.php +++ b/controllers/admin/AdminDPDBalticsProductsAvailabilityController.php @@ -12,6 +12,7 @@ use Invertus\dpdBaltics\Config\Config; use Invertus\dpdBaltics\Controller\AbstractAdminController; use Invertus\dpdBaltics\Exception\ProductAvailabilityUpdateException; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\Provider\ProductAvailabilityProvider; use Invertus\dpdBaltics\Service\Product\ProductAvailabilityService; @@ -61,8 +62,8 @@ public function setMedia($isNewTheme = false) 'saveProgress' => $this->l('Saving...'), ], 'url' => [ - 'productAvailabilityControllerUrl' => $this->context->link->getAdminLink(DPDBaltics::ADMIN_PRODUCT_AVAILABILITY_CONTROLLER), - 'productControllerUrl' => $this->context->link->getAdminLink(DPDBaltics::ADMIN_PRODUCTS_CONTROLLER), + 'productAvailabilityControllerUrl' => $this->context->link->getAdminLink(ModuleTabs::ADMIN_PRODUCT_AVAILABILITY_CONTROLLER), + 'productControllerUrl' => $this->context->link->getAdminLink(ModuleTabs::ADMIN_PRODUCTS_CONTROLLER), ], 'entity' => [ 'productAvailabilityRanges' => $productAvailabilityProvider->getProductAvailabilityForJS(Tools::getValue('id_dpd_product')), diff --git a/controllers/admin/AdminDPDBalticsRequestSupportController.php b/controllers/admin/AdminDPDBalticsRequestSupportController.php index d7ffd7c2..116c6ba0 100644 --- a/controllers/admin/AdminDPDBalticsRequestSupportController.php +++ b/controllers/admin/AdminDPDBalticsRequestSupportController.php @@ -12,6 +12,7 @@ use Invertus\dpdBaltics\Config\Config; use Invertus\dpdBaltics\Controller\AbstractAdminController; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\Service\LogsService; require_once dirname(__DIR__).'/../vendor/autoload.php'; @@ -70,7 +71,7 @@ public function initContent() ], ], 'isLogsOn' => Configuration::get(Config::TRACK_LOGS), - 'downloadLogsAction' => 'index.php?controller=' . DPDBaltics::ADMIN_REQUEST_SUPPORT_CONTROLLER . '&token=' . $this->token, + 'downloadLogsAction' => 'index.php?controller=' . ModuleTabs::ADMIN_REQUEST_SUPPORT_CONTROLLER . '&token=' . $this->token, ]; $this->context->smarty->assign($tplVars); diff --git a/controllers/admin/AdminDPDBalticsSettingsController.php b/controllers/admin/AdminDPDBalticsSettingsController.php index 08a381d9..be47f2bd 100644 --- a/controllers/admin/AdminDPDBalticsSettingsController.php +++ b/controllers/admin/AdminDPDBalticsSettingsController.php @@ -25,6 +25,7 @@ use Invertus\dpdBaltics\Controller\AbstractAdminController; use Invertus\dpdBaltics\DTO\DPDProductInstall; use Invertus\dpdBaltics\Exception\DpdCarrierException; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\Repository\ProductRepository; use Invertus\dpdBaltics\Service\Carrier\CreateCarrierService; use Invertus\dpdBaltics\Service\Carrier\CarrierUpdateHandler; @@ -270,7 +271,7 @@ private function restartOnBoard() Configuration::updateValue(Config::ON_BOARD_STEP, Config::STEP_MAIN_1); Configuration::updateValue(Config::ON_BOARD_MANUAL_CONFIG_CURRENT_PART, 1); - Tools::redirectAdmin($this->context->link->getAdminLink(DPDBaltics::ADMIN_SETTINGS_CONTROLLER)); + Tools::redirectAdmin($this->context->link->getAdminLink(ModuleTabs::ADMIN_SETTINGS_CONTROLLER)); } private function getPasswordPlaceholder() diff --git a/controllers/admin/AdminDPDBalticsShipmentSettingsController.php b/controllers/admin/AdminDPDBalticsShipmentSettingsController.php index f078903f..b8021c3f 100644 --- a/controllers/admin/AdminDPDBalticsShipmentSettingsController.php +++ b/controllers/admin/AdminDPDBalticsShipmentSettingsController.php @@ -21,6 +21,7 @@ use Invertus\dpdBaltics\Config\Config; use Invertus\dpdBaltics\Controller\AbstractAdminController; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\Repository\AddressTemplateRepository; use Invertus\dpdBaltics\Repository\CodPaymentRepository; use Invertus\dpdBaltics\Repository\PaymentRepository; @@ -128,7 +129,7 @@ protected function initOptions() $infoBlockText = $this->module->l('Please move COD modules to the right, non-COD modules leave on the left'); $returnServiceAddresses = $addressTemplateRepo->getReturnServiceAddressTemplates(); if (!$returnServiceAddresses) { - $addressTabRedirect = $this->context->link->getAdminLink(DPDBaltics::ADMIN_ADDRESS_TEMPLATE_CONTROLLER); + $addressTabRedirect = $this->context->link->getAdminLink(ModuleTabs::ADMIN_ADDRESS_TEMPLATE_CONTROLLER); $this->context->smarty->assign( [ 'addressTabRedirect' => $addressTabRedirect diff --git a/controllers/admin/AdminDPDBalticsZonesController.php b/controllers/admin/AdminDPDBalticsZonesController.php index e5f3786a..0fcf56f0 100644 --- a/controllers/admin/AdminDPDBalticsZonesController.php +++ b/controllers/admin/AdminDPDBalticsZonesController.php @@ -15,6 +15,7 @@ use Invertus\dpdBaltics\Controller\AbstractAdminController; use Invertus\dpdBaltics\Exception\ZoneUpdateException; use Invertus\dpdBaltics\Exception\ZoneValidateException; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\OnBoard\Service\OnBoardService; use Invertus\dpdBaltics\OnBoard\Service\OnBoardStepActionService; use Invertus\dpdBaltics\Provider\ZoneRangeProvider; @@ -63,7 +64,7 @@ public function initToolbar() if ($this->display != 'edit' && $this->display != 'add') { $this->toolbar_btn['import'] = [ 'href' => $this->context->link->getAdminLink( - DPDBaltics::ADMIN_IMPORT_EXPORT_CONTROLLER, + ModuleTabs::ADMIN_IMPORT_EXPORT_CONTROLLER, true, [], ['importContr' => Config::IMPORT_EXPORT_OPTION_ZONES] @@ -101,7 +102,7 @@ public function setMedia($isNewTheme = false) 'saveProgress' => $this->l('Saving...'), ], 'url' => [ - 'zonesControllerUrl' => $this->context->link->getAdminLink(DPDBaltics::ADMIN_ZONES_CONTROLLER), + 'zonesControllerUrl' => $this->context->link->getAdminLink(ModuleTabs::ADMIN_ZONES_CONTROLLER), ], 'entity' => [ 'zoneRanges' => $zoneRangeProvider->getZoneRangesForJS(), diff --git a/dpdbaltics.php b/dpdbaltics.php index bf4ede1c..417f5711 100644 --- a/dpdbaltics.php +++ b/dpdbaltics.php @@ -22,7 +22,6 @@ use Invertus\dpdBaltics\Grid\Row\PrintAccessibilityChecker; use Invertus\dpdBaltics\Builder\Template\Front\CarrierOptionsBuilder; use Invertus\dpdBaltics\Config\Config; -use Invertus\dpdBaltics\ConsoleCommand\UpdateParcelShopsCommand; use Invertus\dpdBaltics\Controller\AbstractAdminController; use Invertus\dpdBaltics\Grid\LinkRowActionCustom; use Invertus\dpdBaltics\Grid\SubmitBulkActionCustom; @@ -73,30 +72,6 @@ class DPDBaltics extends CarrierModule { - /** - * Controller for displaying dpd links in prestashop's menu - */ - const ADMIN_DPDBALTICS_MODULE_CONTROLLER = 'AdminDPDBalticsModule'; - - const ADMIN_ZONES_CONTROLLER = 'AdminDPDBalticsZones'; - const ADMIN_PRODUCT_AVAILABILITY_CONTROLLER = 'AdminDPDBalticsProductsAvailability'; - const ADMIN_PRODUCTS_CONTROLLER = 'AdminDPDBalticsProducts'; - const ADMIN_SETTINGS_CONTROLLER = 'AdminDPDBalticsSettings'; - const ADMIN_SHIPMENT_SETTINGS_CONTROLLER = 'AdminDPDBalticsShipmentSettings'; - const ADMIN_IMPORT_EXPORT_CONTROLLER = 'AdminDPDBalticsImportExport'; - const ADMIN_PRICE_RULES_CONTROLLER = 'AdminDPDBalticsPriceRules'; - const ADMIN_ADDRESS_TEMPLATE_CONTROLLER = 'AdminDPDBalticsAddressTemplate'; - const ADMIN_AJAX_CONTROLLER = 'AdminDPDBalticsAjax'; - const ADMIN_PUDO_AJAX_CONTROLLER = 'AdminDPDBalticsPudoAjax'; - const ADMIN_REQUEST_SUPPORT_CONTROLLER = 'AdminDPDBalticsRequestSupport'; - const ADMIN_AJAX_SHIPMENTS_CONTROLLER = 'AdminDPDBalticsAjaxShipments'; - const ADMIN_LOGS_CONTROLLER = 'AdminDPDBalticsLogs'; - const ADMIN_SHIPMENT_CONTROLLER = 'AdminDPDBalticsShipment'; - const ADMIN_ORDER_RETURN_CONTROLLER = 'AdminDPDBalticsOrderReturn'; - const ADMIN_COLLECTION_REQUEST_CONTROLLER = 'AdminDPDBalticsCollectionRequest'; - const ADMIN_COURIER_REQUEST_CONTROLLER = 'AdminDPDBalticsCourierRequest'; - const ADMIN_AJAX_ON_BOARD_CONTROLLER = 'AdminDPDAjaxOnBoard'; - /** * Symfony DI Container **/ @@ -117,7 +92,7 @@ public function __construct() $this->author = 'Invertus'; $this->tab = 'shipping_logistics'; $this->description = 'DPD Baltics shipping integration'; - $this->version = '3.2.15'; + $this->version = '3.2.16'; $this->ps_versions_compliancy = ['min' => '1.7.1.0', 'max' => _PS_VERSION_]; $this->need_instance = 0; parent::__construct(); @@ -132,32 +107,40 @@ public function install() return false; } - /** @var Installer $installer */ - $installer = $this->getModuleContainer()->get('invertus.dpdbaltics.install.installer'); - if (!$installer->install()) { - $this->_errors += $installer->getErrors(); - $this->uninstall(); + /** @var \Invertus\dpdBaltics\Infrastructure\Bootstrap\Install\Installer $installer */ + $installer = $this->getService(\Invertus\dpdBaltics\Infrastructure\Bootstrap\Install\Installer::class); + + try { + $installer->init(); + + return true; + } catch (\Invertus\dpdBaltics\Infrastructure\Bootstrap\Exception\CouldNotInstallModule $exception) { + $this->_errors[] = $exception->getMessage(); return false; } - - return true; } public function uninstall() { - /** @var Installer $installer */ - $installer = $this->moduleContainer->get('invertus.dpdbaltics.install.installer'); - if (!$installer->uninstall()) { - $this->_errors += $installer->getErrors(); + $uninstall = parent::uninstall(); + + if (!$uninstall) { return false; } - if (!parent::uninstall()) { + /** @var \Invertus\dpdBaltics\Infrastructure\Bootstrap\Uninstall\Uninstaller $uninstaller */ + $uninstaller = $this->getService(\Invertus\dpdBaltics\Infrastructure\Bootstrap\Uninstall\Uninstaller::class); + + try { + $uninstaller->init(); + + return true; + } catch (\Invertus\dpdBaltics\Infrastructure\Bootstrap\Exception\CouldNotUninstallModule $exception) { + $this->_errors[] = $exception->getMessage(); + return false; } - - return true; } /** @@ -165,15 +148,20 @@ public function uninstall() */ public function getTabs() { - /** @var TabService $tabsService */ - $tabsService = $this->getModuleContainer()->get('invertus.dpdbaltics.service.tab_service'); + /** @var \Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs $moduleTabs */ + $moduleTabs = $this->getService(\Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs::class); - return $tabsService->getTabs(); + return $moduleTabs->getTabs(); } public function getContent() { - Tools::redirectAdmin($this->context->link->getAdminLink(self::ADMIN_SETTINGS_CONTROLLER)); + Tools::redirectAdmin($this->context->link->getAdminLink(\Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs::ADMIN_SETTINGS_CONTROLLER)); + } + + public function getService($serviceName) + { + return $this->getModuleContainer()->get($serviceName); } /** @@ -193,7 +181,7 @@ public function hookActionFrontControllerSetMedia() //TODO fillup this array when more modules are compatible with OPC $onePageCheckoutControllers = ['supercheckout']; $applicableControlelrs = ['order', 'order-opc', 'ShipmentReturn', 'supercheckout']; - $currentController = $this->context->controller->php_self ?? Tools::getValue('controller'); + $currentController = !empty($this->context->controller->php_self) ? $this->context->controller->php_self : Tools::getValue('controller'); if ('product' === $currentController) { $this->context->controller->registerStylesheet( @@ -736,12 +724,12 @@ public function hookActionAdminControllerSetMedia($params) $currentController = Tools::getValue('controller'); if (Config::isPrestashopVersionBelow174()) { - /** @var $tabs TabService*/ - $tabs = $this->getModuleContainer()->get('invertus.dpdbaltics.service.tab_service'); - $visibleClasses = $tabs->getTabsClassNames(false); + /** @var \Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs $moduleTabs */ + $moduleTabs = $this->getService(\Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs::class); + $visibleClasses = $moduleTabs->getTabsClassNames(false); if (in_array($currentController, $visibleClasses, true)) { - Media::addJsDef(['visibleTabs' => $tabs->getTabsClassNames(true)]); + Media::addJsDef(['visibleTabs' => $moduleTabs->getTabsClassNames(true)]); $this->context->controller->addJS($this->getPathUri() . 'views/js/admin/tabsHandlerBelowPs174.js'); } } @@ -753,7 +741,7 @@ public function hookActionAdminControllerSetMedia($params) $this->context->controller->addJS($this->getPathUri() . 'views/js/admin/order_list.js'); Media::addJsDef( [ - 'dpdHookAjaxShipmentController' => $this->context->link->getAdminLink(self::ADMIN_AJAX_SHIPMENTS_CONTROLLER), + 'dpdHookAjaxShipmentController' => $this->context->link->getAdminLink(\Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs::ADMIN_AJAX_SHIPMENTS_CONTROLLER), 'shipmentIsBeingPrintedMessage' => $this->context->smarty->fetch($this->getLocalPath() . 'views/templates/admin/partials/spinner.tpl') . $this->l('Your labels are being saved please stay on the page'), 'noOrdersSelectedMessage' => $this->l('No orders were selected'), @@ -791,7 +779,7 @@ public function hookActionAdminControllerSetMedia($params) 'expandText' => $this->l('Expand'), 'collapseText' => $this->l('Collapse'), 'dpdAjaxShipmentsUrl' => - $this->context->link->getAdminLink(self::ADMIN_AJAX_SHIPMENTS_CONTROLLER), + $this->context->link->getAdminLink(\Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs::ADMIN_AJAX_SHIPMENTS_CONTROLLER), 'dpdMessages' => [ 'invalidProductQuantity' => $this->l('Invalid product quantity entered'), 'invalidShipment' => $this->l('Invalid shipment selected'), @@ -829,9 +817,9 @@ public function hookActionAdminControllerSetMedia($params) 'pudoCarriers' => json_encode($productRepo->getPudoProducts()), 'currentController' => $currentController, 'dpdAjaxShipmentsUrl' => - $this->context->link->getAdminLink(self::ADMIN_AJAX_SHIPMENTS_CONTROLLER), + $this->context->link->getAdminLink(\Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs::ADMIN_AJAX_SHIPMENTS_CONTROLLER), 'ignoreAdminController' => true, - 'dpdAjaxPudoUrl' => $this->context->link->getAdminLink(self::ADMIN_PUDO_AJAX_CONTROLLER), + 'dpdAjaxPudoUrl' => $this->context->link->getAdminLink(\Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs::ADMIN_PUDO_AJAX_CONTROLLER), 'id_shop' => $this->context->shop->id, ]); @@ -1026,7 +1014,7 @@ private function displayInAdminOrderPage(array $params) 'isAbove177' => Config::isPrestashopVersionAbove177(), 'testOrder' => $shipment->is_test, 'total_products' => 1, - 'contractPageLink' => $this->context->link->getAdminLink(self::ADMIN_PRODUCTS_CONTROLLER), + 'contractPageLink' => $this->context->link->getAdminLink(\Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs::ADMIN_PRODUCTS_CONTROLLER), 'dpdCodWarning' => $dpdCodWarning, 'testMode' => Configuration::get(Config::SHIPMENT_TEST_MODE), 'printLabelOption' => Configuration::get(Config::LABEL_PRINT_OPTION), diff --git a/src/Controller/AbstractAdminController.php b/src/Controller/AbstractAdminController.php index cd31bd34..a40c4382 100644 --- a/src/Controller/AbstractAdminController.php +++ b/src/Controller/AbstractAdminController.php @@ -25,6 +25,7 @@ use DPDBaltics; use Exception; use Invertus\dpdBaltics\Config\Config; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\OnBoard\Service\OnBoardStepActionService; use Invertus\dpdBaltics\Provider\CurrentCountryProvider; use Invertus\dpdBaltics\Provider\ImportExportURLProvider; @@ -83,7 +84,7 @@ public function initPageHeaderToolbar() $importExportUrl = $importExportURLProvider->getImportExportUrl(); $this->page_header_toolbar_btn['logs'] = [ - 'href' => $this->context->link->getAdminLink(DPDBaltics::ADMIN_LOGS_CONTROLLER), + 'href' => $this->context->link->getAdminLink(ModuleTabs::ADMIN_LOGS_CONTROLLER), 'desc' => $this->module->l('Logs', self::FILENAME), 'icon' => 'process-icon-database', ]; @@ -95,7 +96,7 @@ public function initPageHeaderToolbar() ]; $this->page_header_toolbar_btn['request_support'] = [ - 'href' => $this->context->link->getAdminLink(DPDBaltics::ADMIN_REQUEST_SUPPORT_CONTROLLER), + 'href' => $this->context->link->getAdminLink(ModuleTabs::ADMIN_REQUEST_SUPPORT_CONTROLLER), 'desc' => $this->module->l('Request support', self::FILENAME), 'icon' => 'process-icon-newCombination toolbar-new', ]; @@ -132,7 +133,7 @@ public function setMedia($isNewTheme = false) $jsVars['onBoard'] = array( 'stopWarning' => $this->l('Stop DPD on-board?'), 'pauseWarning' => $this->l('Pause DPD on-board?'), - 'ajaxUrl' => $this->context->link->getAdminLink(DPDBaltics::ADMIN_AJAX_ON_BOARD_CONTROLLER), + 'ajaxUrl' => $this->context->link->getAdminLink(ModuleTabs::ADMIN_AJAX_ON_BOARD_CONTROLLER), 'currentStep' => Configuration::get(Config::ON_BOARD_STEP) ); @@ -201,7 +202,7 @@ private function displayTestModeWarning() $this->warnings[] = $this->context->smarty->fetch( $this->module->getLocalPath() . 'views/templates/admin/warning-message-with-link.tpl', [ - 'messageLink' => $this->context->link->getAdminLink(DPDBaltics::ADMIN_IMPORT_EXPORT_CONTROLLER) . "#import-Parcels-button", + 'messageLink' => $this->context->link->getAdminLink(ModuleTabs::ADMIN_IMPORT_EXPORT_CONTROLLER) . "#import-Parcels-button", 'messageStart' => $this->module->l('“Please note: Pick-up carrier is not available for your shop at the moment, because you don’t have pick-up points. To import pick-up points ', self::FILENAME), 'messageEnd' => '', 'linkText' => $this->module->l('click here', self::FILENAME) diff --git a/src/Core/Shared/Repository/LanguageRepository.php b/src/Core/Shared/Repository/LanguageRepository.php new file mode 100644 index 00000000..65ee3d64 --- /dev/null +++ b/src/Core/Shared/Repository/LanguageRepository.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 + */ + +namespace Invertus\dpdBaltics\Core\Shared\Repository; + + +use Invertus\dpdBaltics\Infrastructure\Repository\CollectionRepository; + +class LanguageRepository extends CollectionRepository implements LanguageRepositoryInterface +{ + public function __construct() + { + parent::__construct(\Language::class); + } + + /** {@inheritDoc} */ + public function getAllActive() + { + return $this->findAllInCollection() + ->where('active', '=', true) + ->getResults(); + } +} diff --git a/src/Core/Shared/Repository/LanguageRepositoryInterface.php b/src/Core/Shared/Repository/LanguageRepositoryInterface.php new file mode 100644 index 00000000..baa64a0a --- /dev/null +++ b/src/Core/Shared/Repository/LanguageRepositoryInterface.php @@ -0,0 +1,33 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace Invertus\dpdBaltics\Core\Shared\Repository; + +use Invertus\dpdBaltics\Infrastructure\Repository\ReadOnlyCollectionRepositoryInterface; + +interface LanguageRepositoryInterface extends ReadOnlyCollectionRepositoryInterface +{ + /** + * @return \Language[] + * + * @throws \Exception + */ + public function getAllActive(); +} diff --git a/src/Core/Shared/Repository/TabRepository.php b/src/Core/Shared/Repository/TabRepository.php new file mode 100644 index 00000000..833ca71f --- /dev/null +++ b/src/Core/Shared/Repository/TabRepository.php @@ -0,0 +1,31 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace Invertus\dpdBaltics\Core\Shared\Repository; + +use Invertus\dpdBaltics\Infrastructure\Repository\CollectionRepository; + +class TabRepository extends CollectionRepository implements TabRepositoryInterface +{ + public function __construct() + { + parent::__construct(\Tab::class); + } +} diff --git a/src/Core/Shared/Repository/TabRepositoryInterface.php b/src/Core/Shared/Repository/TabRepositoryInterface.php new file mode 100644 index 00000000..90a67eba --- /dev/null +++ b/src/Core/Shared/Repository/TabRepositoryInterface.php @@ -0,0 +1,27 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace Invertus\dpdBaltics\Core\Shared\Repository; + +use Invertus\dpdBaltics\Infrastructure\Repository\ReadOnlyCollectionRepositoryInterface; + +interface TabRepositoryInterface extends ReadOnlyCollectionRepositoryInterface +{ +} diff --git a/src/Core/Shared/Repository/index.php b/src/Core/Shared/Repository/index.php new file mode 100644 index 00000000..74851d77 --- /dev/null +++ b/src/Core/Shared/Repository/index.php @@ -0,0 +1,30 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/src/Core/Shared/index.php b/src/Core/Shared/index.php new file mode 100644 index 00000000..74851d77 --- /dev/null +++ b/src/Core/Shared/index.php @@ -0,0 +1,30 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/src/Core/index.php b/src/Core/index.php new file mode 100644 index 00000000..74851d77 --- /dev/null +++ b/src/Core/index.php @@ -0,0 +1,30 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/src/Factory/TabFactory.php b/src/Factory/TabFactory.php deleted file mode 100644 index 9cfbdc3f..00000000 --- a/src/Factory/TabFactory.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace Invertus\dpdBaltics\Factory; - -use Invertus\dpdBaltics\Service\TabService; -use Invertus\psModuleTabs\Object\Tab; -use Invertus\psModuleTabs\Object\TabsCollection; - -class TabFactory -{ - /** - * @var TabService - */ - private $tabsService; - - /** - * TabFactory constructor. - * - * @param TabService $tabsService - */ - public function __construct(TabService $tabsService) - { - $this->tabsService = $tabsService; - } - - /** - * @return TabsCollection - */ - public function getTabsCollection() - { - $tabsDataArray = $this->tabsService->getTabs(); - - $tabsObjectsArray = []; - - foreach ($tabsDataArray as $tabData) { - $tabsObjectsArray[] = $this->getTabObject( - $tabData['name'], - $tabData['class_name'], - $tabData['ParentClassName'], - isset($tabData['visible']) ? $tabData['visible'] : false - ); - } - - return new TabsCollection($tabsObjectsArray); - } - - /** - * @param $tabName - * @param $tabClassName - * @param $tabParentClassName - * - * @param bool $isActive - * @return Tab - */ - private function getTabObject($tabName, $tabClassName, $tabParentClassName, $isActive = false) - { - return new Tab($tabName, $tabClassName, $tabParentClassName, $isActive); - } -} diff --git a/src/Infrastructure/Adapter/ModuleFactory.php b/src/Infrastructure/Adapter/ModuleFactory.php new file mode 100644 index 00000000..e6882c2b --- /dev/null +++ b/src/Infrastructure/Adapter/ModuleFactory.php @@ -0,0 +1,16 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/src/Infrastructure/Bootstrap/Exception/CouldNotInstallModule.php b/src/Infrastructure/Bootstrap/Exception/CouldNotInstallModule.php new file mode 100644 index 00000000..b23bcbf7 --- /dev/null +++ b/src/Infrastructure/Bootstrap/Exception/CouldNotInstallModule.php @@ -0,0 +1,39 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace Invertus\dpdBaltics\Infrastructure\Bootstrap\Exception; + +use Invertus\dpdBaltics\Infrastructure\Exception\DpdException; +use Invertus\dpdBaltics\Infrastructure\Exception\ExceptionCode; + +final class CouldNotInstallModule extends DpdException +{ + public static function failedToInstallModuleTab(\Exception $exception, $moduleTab) + { + return new self( + sprintf('Failed to install module tab (%s)', $moduleTab), + ExceptionCode::INFRASTRUCTURE_FAILED_TO_INSTALL_MODULE_TAB, + $exception, + [ + 'module_tab' => $moduleTab, + ] + ); + } +} diff --git a/src/Infrastructure/Bootstrap/Exception/CouldNotUninstallModule.php b/src/Infrastructure/Bootstrap/Exception/CouldNotUninstallModule.php new file mode 100644 index 00000000..913d6ac7 --- /dev/null +++ b/src/Infrastructure/Bootstrap/Exception/CouldNotUninstallModule.php @@ -0,0 +1,39 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace Invertus\dpdBaltics\Infrastructure\Bootstrap\Exception; + +use Invertus\dpdBaltics\Infrastructure\Exception\DpdException; +use Invertus\dpdBaltics\Infrastructure\Exception\ExceptionCode; + +final class CouldNotUninstallModule extends DpdException +{ + public static function failedToUninstallModuleTab(\Exception $exception, $moduleTab) + { + return new self( + sprintf('Failed to uninstall module tab (%s)', $moduleTab), + ExceptionCode::INFRASTRUCTURE_FAILED_TO_UNINSTALL_MODULE_TAB, + $exception, + [ + 'module_tab' => $moduleTab, + ] + ); + } +} diff --git a/src/Infrastructure/Bootstrap/Exception/index.php b/src/Infrastructure/Bootstrap/Exception/index.php new file mode 100644 index 00000000..296d682e --- /dev/null +++ b/src/Infrastructure/Bootstrap/Exception/index.php @@ -0,0 +1,28 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); + +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); +exit; diff --git a/src/Infrastructure/Bootstrap/Install/Installer.php b/src/Infrastructure/Bootstrap/Install/Installer.php new file mode 100644 index 00000000..db21ce65 --- /dev/null +++ b/src/Infrastructure/Bootstrap/Install/Installer.php @@ -0,0 +1,32 @@ +moduleTabInstaller = $moduleTabInstaller; + $this->legacyInstaller = $legacyInstaller; + } + + /** {@inheritDoc} */ + public function init() + { + try { + $this->moduleTabInstaller->init(); + $this->legacyInstaller->install(); + } catch (CouldNotInstallModule $exception) { + throw $exception; + } catch (\Exception $exception) { + throw CouldNotInstallModule::unknownError($exception); + } + } +} \ No newline at end of file diff --git a/src/Infrastructure/Bootstrap/Install/InstallerInterface.php b/src/Infrastructure/Bootstrap/Install/InstallerInterface.php new file mode 100644 index 00000000..7a4566d4 --- /dev/null +++ b/src/Infrastructure/Bootstrap/Install/InstallerInterface.php @@ -0,0 +1,31 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace Invertus\dpdBaltics\Infrastructure\Bootstrap\Install; + +use Invertus\dpdBaltics\Infrastructure\Bootstrap\Exception\CouldNotInstallModule; + +interface InstallerInterface +{ + /** + * @throws CouldNotInstallModule + */ + public function init(); +} diff --git a/src/Infrastructure/Bootstrap/Install/ModuleTabInstaller.php b/src/Infrastructure/Bootstrap/Install/ModuleTabInstaller.php new file mode 100644 index 00000000..492e4ed6 --- /dev/null +++ b/src/Infrastructure/Bootstrap/Install/ModuleTabInstaller.php @@ -0,0 +1,106 @@ + + * @copyright Copyright (c) permanent, INVERTUS, UAB + * @license Addons PrestaShop license limitation + * @see /LICENSE + * + * International Registered Trademark & Property of INVERTUS, UAB + */ +namespace Invertus\dpdBaltics\Infrastructure\Bootstrap\Install; + +use Invertus\dpdBaltics\Core\Shared\Repository\LanguageRepositoryInterface; +use Invertus\dpdBaltics\Core\Shared\Repository\TabRepositoryInterface; +use Invertus\dpdBaltics\Infrastructure\Adapter\ModuleFactory; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\Exception\CouldNotInstallModule; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; +use Invertus\dpdBaltics\Infrastructure\Utility\VersionUtility; +use Tab as PrestashopTab; + +final class ModuleTabInstaller implements InstallerInterface +{ + private $module; + private $moduleTabs; + private $tabRepository; + private $languageRepository; + + public function __construct( + ModuleFactory $moduleFactory, + ModuleTabs $moduleTabs, + TabRepositoryInterface $tabRepository, + LanguageRepositoryInterface $languageRepository + ) { + $this->module = $moduleFactory->getModule(); + $this->moduleTabs = $moduleTabs; + $this->tabRepository = $tabRepository; + $this->languageRepository = $languageRepository; + } + + public function init() + { + /* + * NOTE: PS 170-174 core install module tab command does not check for + * existing tabs and just write new ones. This causes bugs so + * we stop our own tab installer. + * + * Greater versions sometimes throw error about existing tabs + * so installing tabs manually only on PS 16. + */ + if (VersionUtility::isPsVersionGreaterOrEqualTo('1.7.0.0')) { + return; + } + + $tabs = $this->moduleTabs->getTabs(); + + foreach ($tabs as $tab) { + $this->installTab( + $tab['class_name'], + $tab['parent_class_name'], + $tab['name'], + $tab['visible'] + ); + } + } + + /** + * @throws CouldNotInstallModule + */ + private function installTab($className, $parentClassName, $names, $visible) + { + /** @var PrestashopTab|null $tab */ + $tab = $this->tabRepository->findOneBy([ + 'class_name' => $className, + ]); + + /** @var PrestashopTab|null $tab */ + $parentTab = $this->tabRepository->findOneBy([ + 'class_name' => $parentClassName, + ]); + + //NOTE: no need to create it again. + if ($tab) { + return; + } + + $tabEntity = new PrestashopTab(); + $tabEntity->class_name = $className; + $tabEntity->id_parent = $parentTab ? $parentTab->id : 0; + $tabEntity->module = $this->module->name; + $tabEntity->active = $visible; + + /** @var \Language[] $languages */ + $languages = $this->languageRepository->getAllActive(); + + foreach ($languages as $language) { + $tabEntity->name[$language->id] = isset($names[$language->iso_code]) ? pSQL($names[$language->iso_code]) : pSQL($names['en']); + } + + try { + $tabEntity->save(); + } catch (\Exception $exception) { + throw CouldNotInstallModule::failedToInstallModuleTab($exception, $className); + } + } +} diff --git a/src/Infrastructure/Bootstrap/Install/index.php b/src/Infrastructure/Bootstrap/Install/index.php new file mode 100644 index 00000000..74851d77 --- /dev/null +++ b/src/Infrastructure/Bootstrap/Install/index.php @@ -0,0 +1,30 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/src/Infrastructure/Bootstrap/ModuleTabs.php b/src/Infrastructure/Bootstrap/ModuleTabs.php new file mode 100644 index 00000000..0e69c999 --- /dev/null +++ b/src/Infrastructure/Bootstrap/ModuleTabs.php @@ -0,0 +1,222 @@ +module = $moduleFactory->getModule(); + } + + /** + * @return array + */ + public function getTabs() + { + return [ + [ + 'name' => $this->module->displayName, + 'class_name' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'ParentClassName' => 'AdminParentShipping', + 'parent' => 'AdminParentShipping', + 'visible' => true + ], + [ + 'name' => $this->module->l('Shipment', self::FILE_NAME), + 'class_name' => self::ADMIN_SHIPMENT_CONTROLLER, + 'ParentClassName' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'parent' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'module_tab' => true, + 'visible' => true, + ], + [ + 'name' => $this->module->l('Orders returns', self::FILE_NAME), + 'class_name' => self::ADMIN_ORDER_RETURN_CONTROLLER, + 'ParentClassName' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'parent' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'module_tab' => true, + 'visible' => true, + ], + [ + 'name' => $this->module->l('Collection request', self::FILE_NAME), + 'class_name' => self::ADMIN_COLLECTION_REQUEST_CONTROLLER, + 'ParentClassName' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'parent' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'module_tab' => true, + 'visible' => true, + ], + [ + 'name' => $this->module->l('Courier request', self::FILE_NAME), + 'class_name' => self::ADMIN_COURIER_REQUEST_CONTROLLER, + 'ParentClassName' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'parent' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'module_tab' => true, + 'visible' => true, + ], + [ + 'name' => $this->module->l('Addresses', self::FILE_NAME), + 'class_name' => self::ADMIN_ADDRESS_TEMPLATE_CONTROLLER, + 'ParentClassName' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'parent' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'module_tab' => true, + 'visible' => true, + ], + [ + 'name' => $this->module->l('Price rules', self::FILE_NAME), + 'class_name' => self::ADMIN_PRICE_RULES_CONTROLLER, + 'ParentClassName' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'parent' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'module_tab' => true, + 'visible' => true, + ], + [ + 'name' => $this->module->l('Products', self::FILE_NAME), + 'class_name' => self::ADMIN_PRODUCTS_CONTROLLER, + 'ParentClassName' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'parent' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'module_tab' => true, + 'visible' => true, + ], + [ + 'name' => $this->module->l('Products availability', self::FILE_NAME), + 'class_name' => self::ADMIN_PRODUCT_AVAILABILITY_CONTROLLER, + 'ParentClassName' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'parent' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'module_tab' => true, + 'visible' => false, + ], + [ + 'name' => $this->module->l('Zones', self::FILE_NAME), + 'class_name' => self::ADMIN_ZONES_CONTROLLER, + 'ParentClassName' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'parent' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'module_tab' => true, + 'visible' => true, + ], + [ + 'name' => $this->module->l('Shipment Settings', self::FILE_NAME), + 'class_name' => self::ADMIN_SHIPMENT_SETTINGS_CONTROLLER, + 'ParentClassName' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'parent' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'module_tab' => true, + 'visible' => true, + ], + [ + 'name' => $this->module->l('Basic Settings', self::FILE_NAME), + 'class_name' => self::ADMIN_SETTINGS_CONTROLLER, + 'ParentClassName' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'parent' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'module_tab' => true, + 'visible' => true, + ], + [ + 'name' => $this->module->l('Import', self::FILE_NAME), + 'class_name' => self::ADMIN_IMPORT_EXPORT_CONTROLLER, + 'ParentClassName' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'parent' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'module_tab' => true, + 'visible' => false, + ], + [ + 'name' => $this->module->l('Logs', self::FILE_NAME), + 'class_name' => self::ADMIN_LOGS_CONTROLLER, + 'ParentClassName' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'parent' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'module_tab' => true, + 'visible' => false, + ], + [ + 'name' => $this->module->l('Ajax', self::FILE_NAME), + 'class_name' => self::ADMIN_AJAX_CONTROLLER, + 'ParentClassName' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'parent' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'module_tab' => true, + 'visible' => false, + ], + [ + 'name' => $this->module->l('Pudo Ajax', self::FILE_NAME), + 'class_name' => self::ADMIN_PUDO_AJAX_CONTROLLER, + 'ParentClassName' => -1, + 'module_tab' => true, + 'visible' => false, + ], + [ + 'name' => $this->module->l('Request support', self::FILE_NAME), + 'class_name' => self::ADMIN_REQUEST_SUPPORT_CONTROLLER, + 'ParentClassName' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'parent' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'module_tab' => true, + 'visible' => false, + ], + [ + 'name' => $this->module->l('Shipment ajax', self::FILE_NAME), + 'class_name' => self::ADMIN_AJAX_SHIPMENTS_CONTROLLER, + 'ParentClassName' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'parent' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'module_tab' => true, + 'visible' => false, + ], + [ + 'name' => $this->module->l('Ajax on-board', self::FILE_NAME), + 'class_name' => self::ADMIN_AJAX_ON_BOARD_CONTROLLER, + 'ParentClassName' => -1, + ], + ]; + } + + /** + * Filter visible tabs to handle in javascript for ps versiosns below 1704 + */ + public function getTabsClassNames($visible = true) + { + $filtered = []; + $tabs = $this->getTabs(); + + + foreach ($tabs as $tab) { + + if (!$visible) { + $filtered[] = $tab['class_name']; + } + if (isset($tab['visible']) && $tab['visible']) { + $filtered[] = $tab['class_name']; + } + } + return $filtered; + } +} \ No newline at end of file diff --git a/src/Infrastructure/Bootstrap/Uninstall/ModuleTabUninstaller.php b/src/Infrastructure/Bootstrap/Uninstall/ModuleTabUninstaller.php new file mode 100644 index 00000000..86bd2ff0 --- /dev/null +++ b/src/Infrastructure/Bootstrap/Uninstall/ModuleTabUninstaller.php @@ -0,0 +1,71 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace Invertus\dpdBaltics\Infrastructure\Bootstrap\Uninstall; + +use Invertus\dpdBaltics\Core\Shared\Repository\TabRepositoryInterface; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\Exception\CouldNotUninstallModule; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; +use Tab as PrestashopTab; + +class ModuleTabUninstaller implements UninstallerInterface +{ + private $moduleTabs; + private $tabRepository; + + public function __construct( + ModuleTabs $moduleTabs, + TabRepositoryInterface $tabRepository + ) { + $this->moduleTabs = $moduleTabs; + $this->tabRepository = $tabRepository; + } + + public function init() + { + $tabs = $this->moduleTabs->getTabs(); + + foreach ($tabs as $tab) { + $this->uninstallTab($tab['class_name']); + } + } + + /** + * @throws CouldNotUninstallModule + */ + private function uninstallTab($className) + { + /** @var PrestashopTab|null $tab */ + $tab = $this->tabRepository->findOneBy([ + 'class_name' => $className, + ]); + + //NOTE: if it's already deleted we should just continue with our code. + if (!$tab) { + return; + } + + try { + $tab->delete(); + } catch (\Exception $exception) { + throw CouldNotUninstallModule::failedToUninstallModuleTab($exception, $className); + } + } +} diff --git a/src/Infrastructure/Bootstrap/Uninstall/Uninstaller.php b/src/Infrastructure/Bootstrap/Uninstall/Uninstaller.php new file mode 100644 index 00000000..4efe0e2a --- /dev/null +++ b/src/Infrastructure/Bootstrap/Uninstall/Uninstaller.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 + */ + +namespace Invertus\dpdBaltics\Infrastructure\Bootstrap\Uninstall; + +use Invertus\dpdBaltics\Infrastructure\Bootstrap\Exception\CouldNotUninstallModule; + +class Uninstaller implements UninstallerInterface +{ + private $moduleTabUninstaller; + private $legacyInstaller; + + public function __construct( + ModuleTabUninstaller $moduleTabUninstaller, + \Invertus\dpdBaltics\Install\Installer $legacyInstaller //TODO remove it at some point when refactoring happens, currently just using it via adapter + ) { + $this->moduleTabUninstaller = $moduleTabUninstaller; + $this->legacyInstaller = $legacyInstaller; + } + + /** {@inheritDoc} */ + public function init() + { + try { + $this->moduleTabUninstaller->init(); + $this->legacyInstaller->uninstall(); + } catch (CouldNotUninstallModule $exception) { + throw $exception; + } catch (\Exception $exception) { + throw CouldNotUninstallModule::unknownError($exception); + } + } +} diff --git a/src/Infrastructure/Bootstrap/Uninstall/UninstallerInterface.php b/src/Infrastructure/Bootstrap/Uninstall/UninstallerInterface.php new file mode 100644 index 00000000..1118a915 --- /dev/null +++ b/src/Infrastructure/Bootstrap/Uninstall/UninstallerInterface.php @@ -0,0 +1,31 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace Invertus\dpdBaltics\Infrastructure\Bootstrap\Uninstall; + +use Invertus\dpdBaltics\Infrastructure\Bootstrap\Exception\CouldNotUninstallModule; + +interface UninstallerInterface +{ + /** + * @throws CouldNotUninstallModule + */ + public function init(); +} diff --git a/src/Infrastructure/Bootstrap/Uninstall/index.php b/src/Infrastructure/Bootstrap/Uninstall/index.php new file mode 100644 index 00000000..74851d77 --- /dev/null +++ b/src/Infrastructure/Bootstrap/Uninstall/index.php @@ -0,0 +1,30 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/src/Infrastructure/Bootstrap/index.php b/src/Infrastructure/Bootstrap/index.php new file mode 100644 index 00000000..74851d77 --- /dev/null +++ b/src/Infrastructure/Bootstrap/index.php @@ -0,0 +1,30 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/src/Infrastructure/Exception/DpdException.php b/src/Infrastructure/Exception/DpdException.php new file mode 100644 index 00000000..575f6394 --- /dev/null +++ b/src/Infrastructure/Exception/DpdException.php @@ -0,0 +1,65 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace Invertus\dpdBaltics\Infrastructure\Exception; + +use Invertus\dpdBaltics\Infrastructure\Utility\ExceptionUtility; + +class DpdException extends \Exception +{ + private $context; + + final public function __construct( + $internalMessage, + $code, + $previous = null, + array $context = [] + ) { + parent::__construct($internalMessage, $code, $previous); + $this->context = $context; + } + + public function getContext() + { + return $this->context; + } + + public function getExceptions() + { + $exceptions = []; + $exception = $this; + while ($exception) { + $exceptions[] = ExceptionUtility::toArray($exception); + + $exception = $exception->getPrevious(); + } + + return $exceptions; + } + + public static function unknownError(\Exception $exception) + { + return new static( + 'An unknown error error occurred. Please check system logs or contact Bolt support.', + ExceptionCode::UNKNOWN_ERROR, + $exception + ); + } +} diff --git a/src/Infrastructure/Exception/ExceptionCode.php b/src/Infrastructure/Exception/ExceptionCode.php new file mode 100644 index 00000000..26bd6319 --- /dev/null +++ b/src/Infrastructure/Exception/ExceptionCode.php @@ -0,0 +1,32 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace Invertus\dpdBaltics\Infrastructure\Exception; + +//NOTE class to define most used exception codes for our development. +class ExceptionCode +{ + //Infrastructure related code should start with 6*** + const INFRASTRUCTURE_FAILED_TO_INSTALL_MODULE_TAB = 6005; + const INFRASTRUCTURE_FAILED_TO_UNINSTALL_MODULE_TAB = 6006; + + //Any other unhandled codes should start with 9*** + const UNKNOWN_ERROR = 9001; +} diff --git a/src/Infrastructure/Exception/index.php b/src/Infrastructure/Exception/index.php new file mode 100644 index 00000000..74851d77 --- /dev/null +++ b/src/Infrastructure/Exception/index.php @@ -0,0 +1,30 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/src/Infrastructure/Repository/CollectionRepository.php b/src/Infrastructure/Repository/CollectionRepository.php new file mode 100644 index 00000000..4f0c2b06 --- /dev/null +++ b/src/Infrastructure/Repository/CollectionRepository.php @@ -0,0 +1,57 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace Invertus\dpdBaltics\Infrastructure\Repository; + +use PrestaShopCollection; + +class CollectionRepository implements ReadOnlyCollectionRepositoryInterface +{ + /** + * @var string + */ + private $fullyClassifiedClassName; + + /** + * @param string $fullyClassifiedClassName + */ + public function __construct($fullyClassifiedClassName) + { + $this->fullyClassifiedClassName = $fullyClassifiedClassName; + } + + public function findAllInCollection($langId = null) + { + return new PrestaShopCollection($this->fullyClassifiedClassName, $langId); + } + + public function findOneBy(array $keyValueCriteria, $langId = null) + { + $psCollection = new PrestaShopCollection($this->fullyClassifiedClassName, $langId); + + foreach ($keyValueCriteria as $field => $value) { + $psCollection = $psCollection->where($field, '=', $value); + } + + $first = $psCollection->getFirst(); + + return false === $first ? null : $first; + } +} diff --git a/src/Infrastructure/Repository/ReadOnlyCollectionRepositoryInterface.php b/src/Infrastructure/Repository/ReadOnlyCollectionRepositoryInterface.php new file mode 100644 index 00000000..e3e50d3e --- /dev/null +++ b/src/Infrastructure/Repository/ReadOnlyCollectionRepositoryInterface.php @@ -0,0 +1,46 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace Invertus\dpdBaltics\Infrastructure\Repository; + +use ObjectModel; +use PrestaShopCollection; + +interface ReadOnlyCollectionRepositoryInterface +{ + /** + * @param int|null $langId - objects which ussualy are type of array will become strings. E.g + * $product->name is string instead of multidimensional array where key is id_language. + * Always pass language id + * unless there is a special need not to. Synchronization or smth. + * It saves quite a lot performance wise. + * + * @return PrestaShopCollection + */ + public function findAllInCollection($langId = null); + + /** + * @param array $keyValueCriteria - e.g [ 'id_cart' => 5 ] + * @param int|null $langId + * + * @return ObjectModel|null + */ + public function findOneBy(array $keyValueCriteria, $langId = null); +} diff --git a/src/Infrastructure/Repository/index.php b/src/Infrastructure/Repository/index.php new file mode 100644 index 00000000..74851d77 --- /dev/null +++ b/src/Infrastructure/Repository/index.php @@ -0,0 +1,30 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/src/Infrastructure/Utility/ExceptionUtility.php b/src/Infrastructure/Utility/ExceptionUtility.php new file mode 100644 index 00000000..de248b05 --- /dev/null +++ b/src/Infrastructure/Utility/ExceptionUtility.php @@ -0,0 +1,41 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace Invertus\dpdBaltics\Infrastructure\Utility; + +class ExceptionUtility +{ + public static function toArray(\Exception $exception) + { + if (method_exists($exception, 'getContext')) { + $context = $exception->getContext(); + } else { + $context = []; + } + + return [ + 'message' => (string) $exception->getMessage(), + 'code' => (int) $exception->getCode(), + 'file' => (string) $exception->getFile(), + 'line' => (int) $exception->getLine(), + 'context' => $context, + ]; + } +} diff --git a/src/Infrastructure/Utility/VersionUtility.php b/src/Infrastructure/Utility/VersionUtility.php new file mode 100644 index 00000000..8130c901 --- /dev/null +++ b/src/Infrastructure/Utility/VersionUtility.php @@ -0,0 +1,49 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +namespace Invertus\dpdBaltics\Infrastructure\Utility; + +class VersionUtility +{ + public static function isPsVersionLessThan($version) + { + return version_compare(_PS_VERSION_, $version, '<'); + } + + public static function isPsVersionGreaterThan($version) + { + return version_compare(_PS_VERSION_, $version, '>'); + } + + public static function isPsVersionGreaterOrEqualTo($version) + { + return version_compare(_PS_VERSION_, $version, '>='); + } + + public static function isPsVersionLessThanOrEqualTo($version) + { + return version_compare(_PS_VERSION_, $version, '<='); + } + + public static function isPsVersionEqualTo($version) + { + return version_compare(_PS_VERSION_, $version, '='); + } +} diff --git a/src/Infrastructure/Utility/index.php b/src/Infrastructure/Utility/index.php new file mode 100644 index 00000000..74851d77 --- /dev/null +++ b/src/Infrastructure/Utility/index.php @@ -0,0 +1,30 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/src/Infrastructure/index.php b/src/Infrastructure/index.php new file mode 100644 index 00000000..74851d77 --- /dev/null +++ b/src/Infrastructure/index.php @@ -0,0 +1,30 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/src/Install/Installer.php b/src/Install/Installer.php index 91b30fdc..7943125b 100644 --- a/src/Install/Installer.php +++ b/src/Install/Installer.php @@ -33,13 +33,7 @@ use Invertus\dpdBaltics\Config\Config; use Invertus\dpdBaltics\Repository\CarrierRepository; use Invertus\dpdBaltics\Service\Carrier\CreateCarrierService; -use Invertus\dpdBaltics\Factory\TabFactory; use Invertus\dpdBaltics\Service\Label\LabelPositionService; -use Invertus\dpdBaltics\Uninstaller\ModuleTabs\ModuleTabsUninstaller; -use Invertus\psModuleTabs\Object\TabsCollection; -use Invertus\psModuleTabs\Service\TabsInitializer; -use Invertus\psModuleTabs\Service\TabsUninstaller; -use Symfony\Component\Validator\Constraints\Count; use Tools; use Validate; @@ -56,15 +50,6 @@ class Installer */ private $module; - /** - * @var array - */ - private $errors = []; - - /** - * @var TabFactory - */ - private $tabFactory; /** * @var CreateCarrierService @@ -76,91 +61,60 @@ class Installer */ private $carrierRepository; - /** - * Installer constructor. - * @param DPDBaltics $module - * @param CreateCarrierService $createCarriersService - */ public function __construct( DPDBaltics $module, - TabFactory $tabFactory, CreateCarrierService $createCarriersService, CarrierRepository $carrierRepository ) { $this->module = $module; - $this->tabFactory = $tabFactory; $this->createCarriersService = $createCarriersService; $this->carrierRepository = $carrierRepository; } /** - * Get installer errors - * - * @return array|string[] - */ - public function getErrors() - { - return $this->errors; - } - - /** - * @return bool + * @throws \Exception */ public function install() { - if (!$this->installConfiguration()) { - $this->errors[] = $this->module->l('Failed to install configuration', self::FILE_NAME); - return false; - } + //TODO custom exceptions. + //TODO extract messages to translator instead of translating them here. - if (!$this->installTabs()) { - $this->errors[] = $this->module->l('Failed to install tabs', self::FILE_NAME); - return false; + if (!$this->installConfiguration()) { + throw new \Exception($this->module->l('Failed to install configuration', self::FILE_NAME)); } if (!$this->processDatabase(self::DB_ACTION_INSTALL)) { - $this->errors[] = $this->module->l('Failed to install database tables', self::FILE_NAME); - return false; + throw new \Exception($this->module->l('Failed to install database tables', self::FILE_NAME)); } if (!$this->createCarriers()) { - $this->errors[] = $this->module->l('Failed to create carriers', self::FILE_NAME); - return false; + throw new \Exception($this->module->l('Failed to create carriers', self::FILE_NAME)); } if (!$this->registerHooks()) { - $this->errors[] = $this->module->l('Failed to register hooks', self::FILE_NAME); - return false; + throw new \Exception($this->module->l('Failed to register hooks', self::FILE_NAME)); } - - return true; } /** - * Uninstall controllers, hooks, database & etc. - * - * @return bool + * @throws \Exception */ public function uninstall() { + //TODO custom exceptions. + //TODO extract messages to translator instead of translating them here. + if (!$this->uninstallConfiguration()) { - $this->errors[] = $this->module->l('Failed to uninstall configuration', self::FILE_NAME); - return false; + throw new \Exception($this->module->l('Failed to uninstall configuration', self::FILE_NAME)); } - if (!$this->uninstallTabs()) { - $this->errors[] = $this->module->l('Failed to uninstall tabs', self::FILE_NAME); - return false; + if (!$this->processDeleteCarriers()) { + throw new \Exception($this->module->l('Failed to delete carriers', self::FILE_NAME)); } - $this->processDeleteCarriers(); - if (!$this->processDatabase(self::DB_ACTION_UNINSTALL)) { - $this->errors[] = $this->module->l('Failed to uninstall database tables', self::FILE_NAME); - return false; + throw new \Exception($this->module->l('Failed to uninstall database tables', self::FILE_NAME)); } - - return true; } /** @@ -180,10 +134,10 @@ private function processDatabase($action) if (!$this->execute($sqlStatements)) { if (self::DB_ACTION_INSTALL === $action) { - $this->errors[] = sprintf( + throw new \Exception(sprintf( $this->module->l('Failed to execute SQL in file %s', self::FILE_NAME), $sqlFile - ); + )); } return false; } @@ -232,14 +186,7 @@ private function getSqlStatements($fileName) */ public function createCarriers() { - try { - $result = $this->createCarriersService->createCarriers(Config::getProducts()); - } catch (Exception $e) { - $this->errors[] = $e->getMessage(); - $result = false; - } - - return $result; + return $this->createCarriersService->createCarriers(Config::getProducts()); } /** @@ -315,33 +262,6 @@ private function uninstallConfiguration() return true; } - private function installTabs() - { - if (!Config::isPrestashopVersionBelow174()) { - return true; - } - /** @var TabsCollection $tabCollection */ - $tabCollection = $this->tabFactory->getTabsCollection(); - $moduleName = $this->module->name; - $tabsInitializer = new TabsInitializer(_PS_VERSION_, $tabCollection, $moduleName); - - return $tabsInitializer->initializeTabsByPsVersion(); - } - - private function uninstallTabs() - { - if (!Config::isPrestashopVersionBelow174()) { - return true; - } - - /** @var TabsCollection $tabCollection */ - $tabCollection = $this->tabFactory->getTabsCollection()->getTabsCollection(); - - $tabsUninstaller = new ModuleTabsUninstaller($tabCollection); - - return $tabsUninstaller->uninstallTabs(); - } - /** * @throws \PrestaShopDatabaseException * @throws \PrestaShopException diff --git a/src/OnBoard/OnBoardSteps/StepImport1.php b/src/OnBoard/OnBoardSteps/StepImport1.php index 2543e629..d7dd8545 100644 --- a/src/OnBoard/OnBoardSteps/StepImport1.php +++ b/src/OnBoard/OnBoardSteps/StepImport1.php @@ -14,6 +14,7 @@ use DPDBaltics; use Invertus\dpdBaltics\Config\Config; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\OnBoard\AbstractOnBoardStep; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardFastMoveButton; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardParagraph; @@ -52,7 +53,7 @@ public function takeStepData() public function takeStepAction() { if ($this->stepActionService->nextStepIfRightController( - DPDBaltics::ADMIN_IMPORT_EXPORT_CONTROLLER, + ModuleTabs::ADMIN_IMPORT_EXPORT_CONTROLLER, Config::STEP_IMPORT_2 )) { $this->stepActionService->setImportToZip(); diff --git a/src/OnBoard/OnBoardSteps/StepImport2.php b/src/OnBoard/OnBoardSteps/StepImport2.php index ac69cbf5..dc4997f3 100644 --- a/src/OnBoard/OnBoardSteps/StepImport2.php +++ b/src/OnBoard/OnBoardSteps/StepImport2.php @@ -14,6 +14,7 @@ use DPDBaltics; use Invertus\dpdBaltics\Config\Config; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\OnBoard\AbstractOnBoardStep; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardButton; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardFastMoveButton; @@ -79,7 +80,7 @@ public function takeStepData() public function takeStepAction() { $this->stepActionService->ifNotRightControllerReverseStep( - DPDBaltics::ADMIN_IMPORT_EXPORT_CONTROLLER, + ModuleTabs::ADMIN_IMPORT_EXPORT_CONTROLLER, Config::STEP_IMPORT_1 ); diff --git a/src/OnBoard/OnBoardSteps/StepManualPriceRules0.php b/src/OnBoard/OnBoardSteps/StepManualPriceRules0.php index 03303de8..34e200ec 100644 --- a/src/OnBoard/OnBoardSteps/StepManualPriceRules0.php +++ b/src/OnBoard/OnBoardSteps/StepManualPriceRules0.php @@ -14,6 +14,7 @@ use DPDBaltics; use Invertus\dpdBaltics\Config\Config; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\OnBoard\AbstractOnBoardStep; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardFastMoveButton; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardParagraph; @@ -59,7 +60,7 @@ public function takeStepData() public function takeStepAction() { $this->stepActionService->nextStepIfRightController( - DPDBaltics::ADMIN_PRICE_RULES_CONTROLLER, + ModuleTabs::ADMIN_PRICE_RULES_CONTROLLER, Config::STEP_MANUAL_PRICE_RULES_1 ); } diff --git a/src/OnBoard/OnBoardSteps/StepManualPriceRules1.php b/src/OnBoard/OnBoardSteps/StepManualPriceRules1.php index 292a1172..3f70aa9f 100644 --- a/src/OnBoard/OnBoardSteps/StepManualPriceRules1.php +++ b/src/OnBoard/OnBoardSteps/StepManualPriceRules1.php @@ -14,6 +14,7 @@ use DPDBaltics; use Invertus\dpdBaltics\Config\Config; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\OnBoard\AbstractOnBoardStep; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardFastMoveButton; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardParagraph; @@ -74,7 +75,7 @@ public function takeStepData() public function takeStepAction() { $this->stepActionService->ifNotRightControllerReverseStep( - DPDBaltics::ADMIN_PRICE_RULES_CONTROLLER, + ModuleTabs::ADMIN_PRICE_RULES_CONTROLLER, Config::STEP_MANUAL_PRICE_RULES_0 ); diff --git a/src/OnBoard/OnBoardSteps/StepManualPriceRules2.php b/src/OnBoard/OnBoardSteps/StepManualPriceRules2.php index a8f83d20..41e4cf1e 100644 --- a/src/OnBoard/OnBoardSteps/StepManualPriceRules2.php +++ b/src/OnBoard/OnBoardSteps/StepManualPriceRules2.php @@ -14,6 +14,7 @@ use DPDBaltics; use Invertus\dpdBaltics\Config\Config; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\OnBoard\AbstractOnBoardStep; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardButton; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardFastMoveButton; @@ -88,7 +89,7 @@ public function takeStepAction() } $this->stepActionService->ifNotRightControllerReverseStep( - DPDBaltics::ADMIN_PRICE_RULES_CONTROLLER, + ModuleTabs::ADMIN_PRICE_RULES_CONTROLLER, Config::STEP_MANUAL_PRICE_RULES_0 ); diff --git a/src/OnBoard/OnBoardSteps/StepManualPriceRules3.php b/src/OnBoard/OnBoardSteps/StepManualPriceRules3.php index df5e385a..bd97598a 100644 --- a/src/OnBoard/OnBoardSteps/StepManualPriceRules3.php +++ b/src/OnBoard/OnBoardSteps/StepManualPriceRules3.php @@ -14,6 +14,7 @@ use DPDBaltics; use Invertus\dpdBaltics\Config\Config; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\OnBoard\AbstractOnBoardStep; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardButton; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardFastMoveButton; @@ -86,7 +87,7 @@ public function takeStepAction() } $this->stepActionService->ifNotRightControllerReverseStep( - DPDBaltics::ADMIN_PRICE_RULES_CONTROLLER, + ModuleTabs::ADMIN_PRICE_RULES_CONTROLLER, Config::STEP_MANUAL_PRICE_RULES_0 ); diff --git a/src/OnBoard/OnBoardSteps/StepManualPriceRules4.php b/src/OnBoard/OnBoardSteps/StepManualPriceRules4.php index f3271aef..11fb825f 100644 --- a/src/OnBoard/OnBoardSteps/StepManualPriceRules4.php +++ b/src/OnBoard/OnBoardSteps/StepManualPriceRules4.php @@ -14,6 +14,7 @@ use DPDBaltics; use Invertus\dpdBaltics\Config\Config; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\OnBoard\AbstractOnBoardStep; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardButton; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardFastMoveButton; @@ -88,7 +89,7 @@ public function takeStepAction() } $this->stepActionService->ifNotRightControllerReverseStep( - DPDBaltics::ADMIN_PRICE_RULES_CONTROLLER, + ModuleTabs::ADMIN_PRICE_RULES_CONTROLLER, Config::STEP_MANUAL_PRICE_RULES_0 ); diff --git a/src/OnBoard/OnBoardSteps/StepManualPriceRules5.php b/src/OnBoard/OnBoardSteps/StepManualPriceRules5.php index 21ca715e..a8eccf66 100644 --- a/src/OnBoard/OnBoardSteps/StepManualPriceRules5.php +++ b/src/OnBoard/OnBoardSteps/StepManualPriceRules5.php @@ -14,6 +14,7 @@ use DPDBaltics; use Invertus\dpdBaltics\Config\Config; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\OnBoard\AbstractOnBoardStep; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardButton; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardFastMoveButton; @@ -85,7 +86,7 @@ public function takeStepAction() } $this->stepActionService->ifNotRightControllerReverseStep( - DPDBaltics::ADMIN_PRICE_RULES_CONTROLLER, + ModuleTabs::ADMIN_PRICE_RULES_CONTROLLER, Config::STEP_MANUAL_PRICE_RULES_0 ); diff --git a/src/OnBoard/OnBoardSteps/StepManualPriceRules6.php b/src/OnBoard/OnBoardSteps/StepManualPriceRules6.php index ffe6ac20..78b2a36c 100644 --- a/src/OnBoard/OnBoardSteps/StepManualPriceRules6.php +++ b/src/OnBoard/OnBoardSteps/StepManualPriceRules6.php @@ -14,6 +14,7 @@ use DPDBaltics; use Invertus\dpdBaltics\Config\Config; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\OnBoard\AbstractOnBoardStep; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardButton; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardFastMoveButton; @@ -86,7 +87,7 @@ public function takeStepAction() } $this->stepActionService->ifNotRightControllerReverseStep( - DPDBaltics::ADMIN_PRICE_RULES_CONTROLLER, + ModuleTabs::ADMIN_PRICE_RULES_CONTROLLER, Config::STEP_MANUAL_PRICE_RULES_0 ); diff --git a/src/OnBoard/OnBoardSteps/StepManualPriceRules7.php b/src/OnBoard/OnBoardSteps/StepManualPriceRules7.php index 844cc7db..f5747b26 100644 --- a/src/OnBoard/OnBoardSteps/StepManualPriceRules7.php +++ b/src/OnBoard/OnBoardSteps/StepManualPriceRules7.php @@ -14,6 +14,7 @@ use DPDBaltics; use Invertus\dpdBaltics\Config\Config; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\OnBoard\AbstractOnBoardStep; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardButton; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardFastMoveButton; @@ -85,7 +86,7 @@ public function takeStepAction() } $this->stepActionService->ifNotRightControllerReverseStep( - DPDBaltics::ADMIN_PRICE_RULES_CONTROLLER, + ModuleTabs::ADMIN_PRICE_RULES_CONTROLLER, Config::STEP_MANUAL_PRICE_RULES_0 ); diff --git a/src/OnBoard/OnBoardSteps/StepManualPriceRules8.php b/src/OnBoard/OnBoardSteps/StepManualPriceRules8.php index 213c556b..3dfb8098 100644 --- a/src/OnBoard/OnBoardSteps/StepManualPriceRules8.php +++ b/src/OnBoard/OnBoardSteps/StepManualPriceRules8.php @@ -14,6 +14,7 @@ use DPDBaltics; use Invertus\dpdBaltics\Config\Config; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\OnBoard\AbstractOnBoardStep; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardFastMoveButton; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardParagraph; @@ -78,7 +79,7 @@ public function takeStepAction() } $this->stepActionService->ifNotRightControllerReverseStep( - DPDBaltics::ADMIN_PRICE_RULES_CONTROLLER, + ModuleTabs::ADMIN_PRICE_RULES_CONTROLLER, Config::STEP_MANUAL_PRICE_RULES_0 ); diff --git a/src/OnBoard/OnBoardSteps/StepManualProducts0.php b/src/OnBoard/OnBoardSteps/StepManualProducts0.php index ee1f3972..7ca4406c 100644 --- a/src/OnBoard/OnBoardSteps/StepManualProducts0.php +++ b/src/OnBoard/OnBoardSteps/StepManualProducts0.php @@ -14,6 +14,7 @@ use DPDBaltics; use Invertus\dpdBaltics\Config\Config; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\OnBoard\AbstractOnBoardStep; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardFastMoveButton; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardParagraph; @@ -57,7 +58,7 @@ public function takeStepData() public function takeStepAction() { if ($this->stepActionService->nextStepIfRightController( - DPDBaltics::ADMIN_PRODUCTS_CONTROLLER, + ModuleTabs::ADMIN_PRODUCTS_CONTROLLER, Config::STEP_MANUAL_PRODUCTS_2 )) { $this->stepActionService->setManualConfigCompletedSteps(Config::ON_BOARD_PRODUCTS_PART); diff --git a/src/OnBoard/OnBoardSteps/StepManualProducts1.php b/src/OnBoard/OnBoardSteps/StepManualProducts1.php index fbcf71a1..c9320d35 100644 --- a/src/OnBoard/OnBoardSteps/StepManualProducts1.php +++ b/src/OnBoard/OnBoardSteps/StepManualProducts1.php @@ -14,6 +14,7 @@ use DPDBaltics; use Invertus\dpdBaltics\Config\Config; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\OnBoard\AbstractOnBoardStep; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardFastMoveButton; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardParagraph; @@ -69,7 +70,7 @@ public function takeStepData() public function takeStepAction() { $this->stepActionService->ifNotRightControllerReverseStep( - DPDBaltics::ADMIN_PRODUCTS_CONTROLLER, + ModuleTabs::ADMIN_PRODUCTS_CONTROLLER, Config::STEP_MANUAL_PRODUCTS_0 ); diff --git a/src/OnBoard/OnBoardSteps/StepManualProducts2.php b/src/OnBoard/OnBoardSteps/StepManualProducts2.php index 2c45eb4f..d0a5e366 100644 --- a/src/OnBoard/OnBoardSteps/StepManualProducts2.php +++ b/src/OnBoard/OnBoardSteps/StepManualProducts2.php @@ -14,6 +14,7 @@ use DPDBaltics; use Invertus\dpdBaltics\Config\Config; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\OnBoard\AbstractOnBoardStep; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardFastMoveButton; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardParagraph; @@ -81,7 +82,7 @@ public function takeStepAction() } $this->stepActionService->ifNotRightControllerReverseStep( - DPDBaltics::ADMIN_PRODUCTS_CONTROLLER, + ModuleTabs::ADMIN_PRODUCTS_CONTROLLER, Config::STEP_MANUAL_PRODUCTS_0 ); diff --git a/src/OnBoard/OnBoardSteps/StepManualProducts3.php b/src/OnBoard/OnBoardSteps/StepManualProducts3.php index 58998d54..5f54a7fa 100644 --- a/src/OnBoard/OnBoardSteps/StepManualProducts3.php +++ b/src/OnBoard/OnBoardSteps/StepManualProducts3.php @@ -14,6 +14,7 @@ use DPDBaltics; use Invertus\dpdBaltics\Config\Config; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\OnBoard\AbstractOnBoardStep; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardButton; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardFastMoveButton; @@ -89,7 +90,7 @@ public function takeStepAction() } $this->stepActionService->ifNotRightControllerReverseStep( - DPDBaltics::ADMIN_PRODUCTS_CONTROLLER, + ModuleTabs::ADMIN_PRODUCTS_CONTROLLER, Config::STEP_MANUAL_PRODUCTS_0 ); diff --git a/src/OnBoard/OnBoardSteps/StepManualProducts4.php b/src/OnBoard/OnBoardSteps/StepManualProducts4.php index b0c59247..48d4fb49 100644 --- a/src/OnBoard/OnBoardSteps/StepManualProducts4.php +++ b/src/OnBoard/OnBoardSteps/StepManualProducts4.php @@ -14,6 +14,7 @@ use DPDBaltics; use Invertus\dpdBaltics\Config\Config; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\OnBoard\AbstractOnBoardStep; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardButton; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardFastMoveButton; @@ -93,7 +94,7 @@ public function takeStepAction() } $this->stepActionService->ifNotRightControllerReverseStep( - DPDBaltics::ADMIN_PRODUCTS_CONTROLLER, + ModuleTabs::ADMIN_PRODUCTS_CONTROLLER, Config::STEP_MANUAL_PRODUCTS_0 ); diff --git a/src/OnBoard/OnBoardSteps/StepManualProducts5.php b/src/OnBoard/OnBoardSteps/StepManualProducts5.php index 5b2e8f30..83f1ad28 100644 --- a/src/OnBoard/OnBoardSteps/StepManualProducts5.php +++ b/src/OnBoard/OnBoardSteps/StepManualProducts5.php @@ -15,6 +15,7 @@ use Configuration; use DPDBaltics; use Invertus\dpdBaltics\Config\Config; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\OnBoard\AbstractOnBoardStep; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardButton; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardFastMoveButton; @@ -105,7 +106,7 @@ public function takeStepAction() } $this->stepActionService->ifNotRightControllerReverseStep( - DPDBaltics::ADMIN_PRODUCTS_CONTROLLER, + ModuleTabs::ADMIN_PRODUCTS_CONTROLLER, Config::STEP_MANUAL_PRODUCTS_0 ); diff --git a/src/OnBoard/OnBoardSteps/StepManualProducts5Shop.php b/src/OnBoard/OnBoardSteps/StepManualProducts5Shop.php index d35db93f..5f36c392 100644 --- a/src/OnBoard/OnBoardSteps/StepManualProducts5Shop.php +++ b/src/OnBoard/OnBoardSteps/StepManualProducts5Shop.php @@ -14,6 +14,7 @@ use DPDBaltics; use Invertus\dpdBaltics\Config\Config; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\OnBoard\AbstractOnBoardStep; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardButton; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardFastMoveButton; @@ -90,7 +91,7 @@ public function takeStepAction() } $this->stepActionService->ifNotRightControllerReverseStep( - DPDBaltics::ADMIN_PRODUCTS_CONTROLLER, + ModuleTabs::ADMIN_PRODUCTS_CONTROLLER, Config::STEP_MANUAL_PRODUCTS_0 ); diff --git a/src/OnBoard/OnBoardSteps/StepManualProducts6.php b/src/OnBoard/OnBoardSteps/StepManualProducts6.php index a573bc10..9c9fd312 100644 --- a/src/OnBoard/OnBoardSteps/StepManualProducts6.php +++ b/src/OnBoard/OnBoardSteps/StepManualProducts6.php @@ -15,6 +15,7 @@ use Configuration; use DPDBaltics; use Invertus\dpdBaltics\Config\Config; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\OnBoard\AbstractOnBoardStep; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardButton; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardFastMoveButton; @@ -90,7 +91,7 @@ public function takeStepAction() } $this->stepActionService->ifNotRightControllerReverseStep( - DPDBaltics::ADMIN_PRODUCTS_CONTROLLER, + ModuleTabs::ADMIN_PRODUCTS_CONTROLLER, Config::STEP_MANUAL_PRODUCTS_0 ); diff --git a/src/OnBoard/OnBoardSteps/StepManualProducts7.php b/src/OnBoard/OnBoardSteps/StepManualProducts7.php index 1a34b3df..21c06e5c 100644 --- a/src/OnBoard/OnBoardSteps/StepManualProducts7.php +++ b/src/OnBoard/OnBoardSteps/StepManualProducts7.php @@ -15,6 +15,7 @@ use Configuration; use DPDBaltics; use Invertus\dpdBaltics\Config\Config; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\OnBoard\AbstractOnBoardStep; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardButton; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardFastMoveButton; @@ -90,7 +91,7 @@ public function takeStepAction() } $this->stepActionService->ifNotRightControllerReverseStep( - DPDBaltics::ADMIN_PRODUCTS_CONTROLLER, + ModuleTabs::ADMIN_PRODUCTS_CONTROLLER, Config::STEP_MANUAL_PRODUCTS_0 ); diff --git a/src/OnBoard/OnBoardSteps/StepManualProducts8.php b/src/OnBoard/OnBoardSteps/StepManualProducts8.php index 405d18e9..36a2d7cc 100644 --- a/src/OnBoard/OnBoardSteps/StepManualProducts8.php +++ b/src/OnBoard/OnBoardSteps/StepManualProducts8.php @@ -15,6 +15,7 @@ use Configuration; use DPDBaltics; use Invertus\dpdBaltics\Config\Config; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\OnBoard\AbstractOnBoardStep; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardFastMoveButton; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardParagraph; @@ -89,7 +90,7 @@ public function takeStepAction() } $this->stepActionService->ifNotRightControllerReverseStep( - DPDBaltics::ADMIN_PRODUCTS_CONTROLLER, + ModuleTabs::ADMIN_PRODUCTS_CONTROLLER, Config::STEP_MANUAL_PRODUCTS_0 ); diff --git a/src/OnBoard/OnBoardSteps/StepManualProducts9.php b/src/OnBoard/OnBoardSteps/StepManualProducts9.php index dd2a9d36..34d31f40 100644 --- a/src/OnBoard/OnBoardSteps/StepManualProducts9.php +++ b/src/OnBoard/OnBoardSteps/StepManualProducts9.php @@ -14,6 +14,7 @@ use DPDBaltics; use Invertus\dpdBaltics\Config\Config; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\OnBoard\AbstractOnBoardStep; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardFastMoveButton; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardParagraph; @@ -76,7 +77,7 @@ public function takeStepData() public function takeStepAction() { if ($this->stepActionService->nextStepIfRightController( - DPDBaltics::ADMIN_PRICE_RULES_CONTROLLER, + ModuleTabs::ADMIN_PRICE_RULES_CONTROLLER, Config::STEP_MANUAL_PRICE_RULES_1 )) { $this->stepActionService->setManualConfigCompletedSteps(Config::ON_BOARD_PRICE_RULES_PART); diff --git a/src/OnBoard/OnBoardSteps/StepManualZones0.php b/src/OnBoard/OnBoardSteps/StepManualZones0.php index 59fdc403..0add626f 100644 --- a/src/OnBoard/OnBoardSteps/StepManualZones0.php +++ b/src/OnBoard/OnBoardSteps/StepManualZones0.php @@ -14,6 +14,7 @@ use DPDBaltics; use Invertus\dpdBaltics\Config\Config; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\OnBoard\AbstractOnBoardStep; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardFastMoveButton; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardParagraph; @@ -58,7 +59,7 @@ public function takeStepData() public function takeStepAction() { if ($this->stepActionService->nextStepIfRightController( - DPDBaltics::ADMIN_ZONES_CONTROLLER, + ModuleTabs::ADMIN_ZONES_CONTROLLER, Config::STEP_MANUAL_ZONES_2 )) { $this->stepActionService->setManualConfigCompletedSteps(Config::ON_BOARD_ZONES_PART); diff --git a/src/OnBoard/OnBoardSteps/StepManualZones1.php b/src/OnBoard/OnBoardSteps/StepManualZones1.php index 3a2ddda1..58b754fe 100644 --- a/src/OnBoard/OnBoardSteps/StepManualZones1.php +++ b/src/OnBoard/OnBoardSteps/StepManualZones1.php @@ -14,6 +14,7 @@ use DPDBaltics; use Invertus\dpdBaltics\Config\Config; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\OnBoard\AbstractOnBoardStep; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardButton; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardFastMoveButton; @@ -67,7 +68,7 @@ public function takeStepData() public function takeStepAction() { if ($this->stepActionService->nextStepIfRightController( - DPDBaltics::ADMIN_ZONES_CONTROLLER, + ModuleTabs::ADMIN_ZONES_CONTROLLER, Config::STEP_MANUAL_ZONES_2 )) { $this->stepActionService->setManualConfigCompletedSteps(Config::ON_BOARD_ZONES_PART); diff --git a/src/OnBoard/OnBoardSteps/StepManualZones2.php b/src/OnBoard/OnBoardSteps/StepManualZones2.php index 801ff584..9526d668 100644 --- a/src/OnBoard/OnBoardSteps/StepManualZones2.php +++ b/src/OnBoard/OnBoardSteps/StepManualZones2.php @@ -14,6 +14,7 @@ use DPDBaltics; use Invertus\dpdBaltics\Config\Config; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\OnBoard\AbstractOnBoardStep; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardFastMoveButton; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardParagraph; @@ -74,7 +75,7 @@ public function takeStepData() public function takeStepAction() { $this->stepActionService->ifNotRightControllerReverseStep( - DPDBaltics::ADMIN_ZONES_CONTROLLER, + ModuleTabs::ADMIN_ZONES_CONTROLLER, Config::STEP_MANUAL_ZONES_0 ); diff --git a/src/OnBoard/OnBoardSteps/StepManualZones3.php b/src/OnBoard/OnBoardSteps/StepManualZones3.php index 5d5e1c8f..f60e45f6 100644 --- a/src/OnBoard/OnBoardSteps/StepManualZones3.php +++ b/src/OnBoard/OnBoardSteps/StepManualZones3.php @@ -14,6 +14,7 @@ use DPDBaltics; use Invertus\dpdBaltics\Config\Config; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\OnBoard\AbstractOnBoardStep; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardButton; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardFastMoveButton; @@ -86,7 +87,7 @@ public function takeStepAction() } $this->stepActionService->ifNotRightControllerReverseStep( - DPDBaltics::ADMIN_ZONES_CONTROLLER, + ModuleTabs::ADMIN_ZONES_CONTROLLER, Config::STEP_MANUAL_ZONES_0 ); diff --git a/src/OnBoard/OnBoardSteps/StepManualZones4.php b/src/OnBoard/OnBoardSteps/StepManualZones4.php index c8cb64d1..82b22f43 100644 --- a/src/OnBoard/OnBoardSteps/StepManualZones4.php +++ b/src/OnBoard/OnBoardSteps/StepManualZones4.php @@ -14,6 +14,7 @@ use DPDBaltics; use Invertus\dpdBaltics\Config\Config; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\OnBoard\AbstractOnBoardStep; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardButton; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardFastMoveButton; @@ -82,7 +83,7 @@ public function takeStepAction() } $this->stepActionService->ifNotRightControllerReverseStep( - DPDBaltics::ADMIN_ZONES_CONTROLLER, + ModuleTabs::ADMIN_ZONES_CONTROLLER, Config::STEP_MANUAL_ZONES_0 ); diff --git a/src/OnBoard/OnBoardSteps/StepManualZones5.php b/src/OnBoard/OnBoardSteps/StepManualZones5.php index 3e315ecc..a7f5b696 100644 --- a/src/OnBoard/OnBoardSteps/StepManualZones5.php +++ b/src/OnBoard/OnBoardSteps/StepManualZones5.php @@ -14,6 +14,7 @@ use DPDBaltics; use Invertus\dpdBaltics\Config\Config; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\OnBoard\AbstractOnBoardStep; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardButton; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardFastMoveButton; @@ -85,7 +86,7 @@ public function takeStepAction() } $this->stepActionService->ifNotRightControllerReverseStep( - DPDBaltics::ADMIN_ZONES_CONTROLLER, + ModuleTabs::ADMIN_ZONES_CONTROLLER, Config::STEP_MANUAL_ZONES_0 ); diff --git a/src/OnBoard/OnBoardSteps/StepManualZones6.php b/src/OnBoard/OnBoardSteps/StepManualZones6.php index 60cf55a7..3b93f03f 100644 --- a/src/OnBoard/OnBoardSteps/StepManualZones6.php +++ b/src/OnBoard/OnBoardSteps/StepManualZones6.php @@ -15,6 +15,7 @@ use Configuration; use DPDBaltics; use Invertus\dpdBaltics\Config\Config; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; use Invertus\dpdBaltics\OnBoard\AbstractOnBoardStep; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardFastMoveButton; use Invertus\dpdBaltics\OnBoard\Objects\OnBoardParagraph; @@ -92,7 +93,7 @@ public function takeStepData() public function takeStepAction() { if ($this->stepActionService->nextStepIfRightController( - DPDBaltics::ADMIN_PRODUCTS_CONTROLLER, + ModuleTabs::ADMIN_PRODUCTS_CONTROLLER, Config::STEP_MANUAL_PRODUCTS_2 )) { $this->stepActionService->setManualConfigCompletedSteps(Config::ON_BOARD_PRODUCTS_PART); diff --git a/src/Provider/ImportExportURLProvider.php b/src/Provider/ImportExportURLProvider.php index c0d0b501..3d227db8 100644 --- a/src/Provider/ImportExportURLProvider.php +++ b/src/Provider/ImportExportURLProvider.php @@ -15,6 +15,7 @@ use Context; use DPDBaltics; use Invertus\dpdBaltics\Config\Config; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs; class ImportExportURLProvider { @@ -28,7 +29,7 @@ public function __construct(Context $context) public function getImportExportUrl() { return $this->context->link->getAdminLink( - DPDBaltics::ADMIN_IMPORT_EXPORT_CONTROLLER, + ModuleTabs::ADMIN_IMPORT_EXPORT_CONTROLLER, true ); } diff --git a/src/Service/TabService.php b/src/Service/TabService.php deleted file mode 100644 index 5c1e77e1..00000000 --- a/src/Service/TabService.php +++ /dev/null @@ -1,215 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - - -namespace Invertus\dpdBaltics\Service; - -use DPDBaltics; - -class TabService -{ - const FILE_NAME = 'TabService'; - - /** - * @var DPDBaltics - */ - private $module; - - public function __construct(DPDBaltics $module) - { - $this->module = $module; - } - - /** - * @return array - */ - public function getTabs() - { - return [ - [ - 'name' => $this->module->displayName, - 'class_name' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'ParentClassName' => 'AdminParentShipping', - 'parent' => 'AdminParentShipping' - ], - [ - 'name' => $this->module->l('Shipment', self::FILE_NAME), - 'class_name' => DPDBaltics::ADMIN_SHIPMENT_CONTROLLER, - 'ParentClassName' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'parent' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'module_tab' => true, - 'visible' => true, - ], - [ - 'name' => $this->module->l('Orders returns', self::FILE_NAME), - 'class_name' => DPDBaltics::ADMIN_ORDER_RETURN_CONTROLLER, - 'ParentClassName' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'parent' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'module_tab' => true, - 'visible' => true, - ], - [ - 'name' => $this->module->l('Collection request', self::FILE_NAME), - 'class_name' => DPDBaltics::ADMIN_COLLECTION_REQUEST_CONTROLLER, - 'ParentClassName' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'parent' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'module_tab' => true, - 'visible' => true, - ], - [ - 'name' => $this->module->l('Courier request', self::FILE_NAME), - 'class_name' => DPDBaltics::ADMIN_COURIER_REQUEST_CONTROLLER, - 'ParentClassName' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'parent' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'module_tab' => true, - 'visible' => true, - ], - [ - 'name' => $this->module->l('Addresses', self::FILE_NAME), - 'class_name' => DPDBaltics::ADMIN_ADDRESS_TEMPLATE_CONTROLLER, - 'ParentClassName' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'parent' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'module_tab' => true, - 'visible' => true, - ], - [ - 'name' => $this->module->l('Price rules', self::FILE_NAME), - 'class_name' => DPDBaltics::ADMIN_PRICE_RULES_CONTROLLER, - 'ParentClassName' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'parent' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'module_tab' => true, - 'visible' => true, - ], - [ - 'name' => $this->module->l('Products', self::FILE_NAME), - 'class_name' => DPDBaltics::ADMIN_PRODUCTS_CONTROLLER, - 'ParentClassName' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'parent' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'module_tab' => true, - 'visible' => true, - ], - [ - 'name' => $this->module->l('Products availability', self::FILE_NAME), - 'class_name' => DPDBaltics::ADMIN_PRODUCT_AVAILABILITY_CONTROLLER, - 'ParentClassName' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'parent' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'module_tab' => true, - 'visible' => false, - ], - [ - 'name' => $this->module->l('Zones', self::FILE_NAME), - 'class_name' => DPDBaltics::ADMIN_ZONES_CONTROLLER, - 'ParentClassName' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'parent' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'module_tab' => true, - 'visible' => true, - ], - [ - 'name' => $this->module->l('Shipment Settings', self::FILE_NAME), - 'class_name' => DPDBaltics::ADMIN_SHIPMENT_SETTINGS_CONTROLLER, - 'ParentClassName' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'parent' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'module_tab' => true, - 'visible' => true, - ], - [ - 'name' => $this->module->l('Basic Settings', self::FILE_NAME), - 'class_name' => DPDBaltics::ADMIN_SETTINGS_CONTROLLER, - 'ParentClassName' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'parent' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'module_tab' => true, - 'visible' => true, - ], - [ - 'name' => $this->module->l('Import', self::FILE_NAME), - 'class_name' => DPDBaltics::ADMIN_IMPORT_EXPORT_CONTROLLER, - 'ParentClassName' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'parent' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'module_tab' => true, - 'visible' => false, - ], - [ - 'name' => $this->module->l('Logs', self::FILE_NAME), - 'class_name' => DPDBaltics::ADMIN_LOGS_CONTROLLER, - 'ParentClassName' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'parent' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'module_tab' => true, - 'visible' => false, - ], - [ - 'name' => $this->module->l('Ajax', self::FILE_NAME), - 'class_name' => DPDBaltics::ADMIN_AJAX_CONTROLLER, - 'ParentClassName' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'parent' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'module_tab' => true, - 'visible' => false, - ], - [ - 'name' => $this->module->l('Pudo Ajax', self::FILE_NAME), - 'class_name' => DPDBaltics::ADMIN_PUDO_AJAX_CONTROLLER, - 'ParentClassName' => -1, - 'module_tab' => true, - 'visible' => false, - ], - [ - 'name' => $this->module->l('Request support', self::FILE_NAME), - 'class_name' => DPDBaltics::ADMIN_REQUEST_SUPPORT_CONTROLLER, - 'ParentClassName' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'parent' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'module_tab' => true, - 'visible' => false, - ], - [ - 'name' => $this->module->l('Shipment ajax', self::FILE_NAME), - 'class_name' => DPDBaltics::ADMIN_AJAX_SHIPMENTS_CONTROLLER, - 'ParentClassName' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'parent' => DPDBaltics::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'module_tab' => true, - 'visible' => false, - ], - [ - 'name' => $this->module->l('Ajax on-board', self::FILE_NAME), - 'class_name' => DPDBaltics::ADMIN_AJAX_ON_BOARD_CONTROLLER, - 'ParentClassName' => -1, - ], - ]; - } - - /** - * Filter visible tabs to handle in javascript for ps versiosns below 1704 - */ - public function getTabsClassNames($visible = true) - { - $filtered = []; - $tabs = $this->getTabs(); - - - foreach ($tabs as $tab) { - - if (!$visible) { - $filtered[] = $tab['class_name']; - } - if (isset($tab['visible']) && $tab['visible']) { - $filtered[] = $tab['class_name']; - } - } - return $filtered; - } -} diff --git a/src/Util/FileDownload.php b/src/Util/FileDownload.php index 08337df5..61adfa96 100644 --- a/src/Util/FileDownload.php +++ b/src/Util/FileDownload.php @@ -81,4 +81,4 @@ public function dumpFile($content, $name, $format) unlink($tmpFolder.$file); } } -} +} \ No newline at end of file diff --git a/upgrade/Upgrade-1.1.1.php b/upgrade/Upgrade-1.1.1.php index f44ca8cc..ceda43c3 100644 --- a/upgrade/Upgrade-1.1.1.php +++ b/upgrade/Upgrade-1.1.1.php @@ -11,13 +11,9 @@ */ use Invertus\dpdBaltics\Config\Config; -use Invertus\dpdBaltics\Factory\TabFactory; -use Invertus\dpdBaltics\Install\Installer; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\Install\ModuleTabInstaller; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\Uninstall\ModuleTabUninstaller; use Invertus\dpdBaltics\Provider\CurrentCountryProvider; -use Invertus\psModuleTabs\Object\Tab; -use Invertus\psModuleTabs\Object\TabsCollection; -use Invertus\psModuleTabs\Service\TabsInitializer; -use Invertus\psModuleTabs\Service\TabsInstaller; if (!defined('_PS_VERSION_')) { exit; @@ -31,30 +27,26 @@ */ function upgrade_module_1_1_1(DPDBaltics $module) { - $db = Db::getInstance(); - $dbQuery = new DbQuery(); - $dbQuery->select('id_tab'); - $dbQuery->from('tab'); - $dbQuery->where("`module` = '" . pSQL($module->name) . "'"); - $tabs = $db->executeS($dbQuery); - foreach ($tabs as $tab) { - $tabClass = new TabCore($tab['id_tab']); - $tabClass->delete(); - } + /** @var ModuleTabUninstaller $moduleTabUninstaller */ + $moduleTabUninstaller = $module->getService(ModuleTabUninstaller::class); + + /** @var ModuleTabInstaller $moduleTabInstaller */ + $moduleTabInstaller = $module->getService(ModuleTabInstaller::class); - /** @var TabFactory $tabFactory */ - $tabFactory = $module->getModuleContainer('invertus.dpdbaltics.factory.tab_factory'); + $result = true; - $tabsInstaller = new TabsInstaller($tabFactory->getTabsCollection(), $module->name); - if (!$tabsInstaller->installTabs()) { - return false; - }; + try { + $moduleTabUninstaller->init(); + $moduleTabInstaller->init(); + } catch (Exception $exception) { + $result &= false; + } /** @var CurrentCountryProvider $currentCountryProvider */ - $currentCountryProvider = $module->getModuleContainer('invertus.dpdbaltics.provider.current_country_provider'); + $currentCountryProvider = $module->getService('invertus.dpdbaltics.provider.current_country_provider'); $countryCode = $currentCountryProvider->getCurrentCountryIsoCode(); Configuration::updateValue(Config::DPD_PARCEL_IMPORT_COUNTRY_SELECTOR, Country::getByIso($countryCode)); - return true; + return $result; } diff --git a/upgrade/Upgrade-1.1.2.php b/upgrade/Upgrade-1.1.2.php index cf9fee0f..e74626e6 100644 --- a/upgrade/Upgrade-1.1.2.php +++ b/upgrade/Upgrade-1.1.2.php @@ -11,7 +11,6 @@ */ use Invertus\dpdBaltics\Config\Config; -use Invertus\dpdBaltics\Factory\TabFactory; use Invertus\dpdBaltics\Install\Installer; use Invertus\dpdBaltics\Provider\CurrentCountryProvider; use Invertus\dpdBaltics\Repository\ProductRepository; diff --git a/upgrade/Upgrade-1.1.5.php b/upgrade/Upgrade-1.1.5.php index 8095a956..5a538b19 100644 --- a/upgrade/Upgrade-1.1.5.php +++ b/upgrade/Upgrade-1.1.5.php @@ -11,7 +11,6 @@ */ use Invertus\dpdBaltics\Config\Config; -use Invertus\dpdBaltics\Factory\TabFactory; use Invertus\dpdBaltics\Install\Installer; use Invertus\dpdBaltics\Repository\ProductRepository; use Invertus\dpdBaltics\Service\Product\ProductService; diff --git a/upgrade/Upgrade-3.2.16.php b/upgrade/Upgrade-3.2.16.php new file mode 100644 index 00000000..ae4fa1cd --- /dev/null +++ b/upgrade/Upgrade-3.2.16.php @@ -0,0 +1,41 @@ + + * @copyright Copyright (c) permanent, INVERTUS, UAB + * @license Addons PrestaShop license limitation + * @see /LICENSE + * + * International Registered Trademark & Property of INVERTUS, UAB + */ + +use Invertus\dpdBaltics\Infrastructure\Bootstrap\Install\ModuleTabInstaller; +use Invertus\dpdBaltics\Infrastructure\Bootstrap\Uninstall\ModuleTabUninstaller; + +if (!defined('_PS_VERSION_')) { + exit; +} + +/** + * @return bool + */ +function upgrade_module_3_2_16(DPDBaltics $module) +{ + /** @var ModuleTabUninstaller $moduleTabUninstaller */ + $moduleTabUninstaller = $module->getService(ModuleTabUninstaller::class); + + /** @var ModuleTabInstaller $moduleTabInstaller */ + $moduleTabInstaller = $module->getService(ModuleTabInstaller::class); + + $result = true; + + try { + $moduleTabUninstaller->init(); + $moduleTabInstaller->init(); + } catch (Exception $exception) { + $result &= false; + } + + return $result; +} From 53142f4582933af22f1c9c4c2b9fd38933c14858 Mon Sep 17 00:00:00 2001 From: GytisZum <96050852+GytisZum@users.noreply.github.com> Date: Wed, 5 Jul 2023 13:17:37 +0300 Subject: [PATCH 02/20] DGS-271 Error on pudo orders with incorrect post code (#106) * fix: api error with wrong address post code fix for pudo orders * fix: refactored other if statement --- src/Service/API/ShipmentApiService.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Service/API/ShipmentApiService.php b/src/Service/API/ShipmentApiService.php index 588db3dd..aca8034f 100644 --- a/src/Service/API/ShipmentApiService.php +++ b/src/Service/API/ShipmentApiService.php @@ -102,12 +102,16 @@ public function createShipment($addressId, ShipmentData $shipmentData, $orderId) $postCode = $address->postcode; $hasAddressFields = (bool) !$postCode || !$firstName || !$address->city || !$country; - // IF prestashop allows, we take selected parcel terminal address in case information is missing in checkout address in specific cases. - if (($hasAddressFields) && $shipmentData->isPudo()) { + // Post code might be wrong in order adress, so we set terminal post code instead + if ($shipmentData->isPudo()) { $parcel = $this->parcelShopService->getParcelShopByShopId($shipmentData->getSelectedPudoId()); $selectedParcel = is_array($parcel) ? reset($parcel) : $parcel; - $firstName = $selectedParcel->getCompany(); $postCode = $selectedParcel->getPCode(); + } + + // IF prestashop allows, we take selected parcel terminal address in case information is missing in checkout address in specific cases. + if (($hasAddressFields) && $shipmentData->isPudo()) { + $firstName = $selectedParcel->getCompany(); $address->address1 = $selectedParcel->getStreet(); $address->city = $selectedParcel->getCity(); $country = $selectedParcel->getCountry(); From f9cf7801d263d94cbd1ce1ad7a6045588449a6bf Mon Sep 17 00:00:00 2001 From: Tomas J <72136043+tomjas1997@users.noreply.github.com> Date: Thu, 20 Jul 2023 10:50:25 +0300 Subject: [PATCH 03/20] Update DpdException.php --- src/Infrastructure/Exception/DpdException.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Infrastructure/Exception/DpdException.php b/src/Infrastructure/Exception/DpdException.php index 575f6394..5ec8b7db 100644 --- a/src/Infrastructure/Exception/DpdException.php +++ b/src/Infrastructure/Exception/DpdException.php @@ -57,7 +57,7 @@ public function getExceptions() public static function unknownError(\Exception $exception) { return new static( - 'An unknown error error occurred. Please check system logs or contact Bolt support.', + 'An unknown error error occurred. Please check system logs or contact Dpd support.', ExceptionCode::UNKNOWN_ERROR, $exception ); From 69b420dfbca2dd954a69602b220de622837edcb1 Mon Sep 17 00:00:00 2001 From: tomjas1997 Date: Fri, 4 Aug 2023 15:17:41 +0300 Subject: [PATCH 04/20] Fixes --- dpdbaltics.php | 11 -- .../Bootstrap/Install/ModuleTabInstaller.php | 14 +-- src/Infrastructure/Bootstrap/ModuleTabs.php | 115 ++++++++++++------ upgrade/Upgrade-3.2.16.php | 30 +++-- 4 files changed, 101 insertions(+), 69 deletions(-) diff --git a/dpdbaltics.php b/dpdbaltics.php index 417f5711..2eb1fa65 100644 --- a/dpdbaltics.php +++ b/dpdbaltics.php @@ -143,17 +143,6 @@ public function uninstall() } } - /** - * @return array - */ - public function getTabs() - { - /** @var \Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs $moduleTabs */ - $moduleTabs = $this->getService(\Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs::class); - - return $moduleTabs->getTabs(); - } - public function getContent() { Tools::redirectAdmin($this->context->link->getAdminLink(\Invertus\dpdBaltics\Infrastructure\Bootstrap\ModuleTabs::ADMIN_SETTINGS_CONTROLLER)); diff --git a/src/Infrastructure/Bootstrap/Install/ModuleTabInstaller.php b/src/Infrastructure/Bootstrap/Install/ModuleTabInstaller.php index 492e4ed6..d60903db 100644 --- a/src/Infrastructure/Bootstrap/Install/ModuleTabInstaller.php +++ b/src/Infrastructure/Bootstrap/Install/ModuleTabInstaller.php @@ -40,18 +40,6 @@ public function __construct( public function init() { - /* - * NOTE: PS 170-174 core install module tab command does not check for - * existing tabs and just write new ones. This causes bugs so - * we stop our own tab installer. - * - * Greater versions sometimes throw error about existing tabs - * so installing tabs manually only on PS 16. - */ - if (VersionUtility::isPsVersionGreaterOrEqualTo('1.7.0.0')) { - return; - } - $tabs = $this->moduleTabs->getTabs(); foreach ($tabs as $tab) { @@ -86,7 +74,7 @@ private function installTab($className, $parentClassName, $names, $visible) $tabEntity = new PrestashopTab(); $tabEntity->class_name = $className; - $tabEntity->id_parent = $parentTab ? $parentTab->id : 0; + $tabEntity->id_parent = $parentTab ? $parentTab->id : -1; $tabEntity->module = $this->module->name; $tabEntity->active = $visible; diff --git a/src/Infrastructure/Bootstrap/ModuleTabs.php b/src/Infrastructure/Bootstrap/ModuleTabs.php index 0e69c999..56cc16cd 100644 --- a/src/Infrastructure/Bootstrap/ModuleTabs.php +++ b/src/Infrastructure/Bootstrap/ModuleTabs.php @@ -50,151 +50,190 @@ public function getTabs() { return [ [ - 'name' => $this->module->displayName, + 'name' => [ + 'en' => $this->module->displayName + ], 'class_name' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, - 'ParentClassName' => 'AdminParentShipping', + 'parent_class_name' => 'AdminParentShipping', 'parent' => 'AdminParentShipping', 'visible' => true ], [ - 'name' => $this->module->l('Shipment', self::FILE_NAME), + 'name' => [ + 'en' => 'Shipment' + ], 'class_name' => self::ADMIN_SHIPMENT_CONTROLLER, - 'ParentClassName' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'parent_class_name' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, 'parent' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, 'module_tab' => true, 'visible' => true, ], [ - 'name' => $this->module->l('Orders returns', self::FILE_NAME), + 'name' => [ + 'en' => 'Orders returns' + ], 'class_name' => self::ADMIN_ORDER_RETURN_CONTROLLER, - 'ParentClassName' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'parent_class_name' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, 'parent' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, 'module_tab' => true, 'visible' => true, ], [ - 'name' => $this->module->l('Collection request', self::FILE_NAME), + 'name' => [ + 'en' => 'Collection request' + ], 'class_name' => self::ADMIN_COLLECTION_REQUEST_CONTROLLER, - 'ParentClassName' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'parent_class_name' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, 'parent' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, 'module_tab' => true, 'visible' => true, ], [ - 'name' => $this->module->l('Courier request', self::FILE_NAME), + 'name' => [ + 'en' => 'Courier request' + ], 'class_name' => self::ADMIN_COURIER_REQUEST_CONTROLLER, - 'ParentClassName' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'parent_class_name' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, 'parent' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, 'module_tab' => true, 'visible' => true, ], [ - 'name' => $this->module->l('Addresses', self::FILE_NAME), + 'name' => [ + 'en' => 'Addresses' + ], 'class_name' => self::ADMIN_ADDRESS_TEMPLATE_CONTROLLER, - 'ParentClassName' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'parent_class_name' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, 'parent' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, 'module_tab' => true, 'visible' => true, ], [ - 'name' => $this->module->l('Price rules', self::FILE_NAME), + 'name' => [ + 'en' => 'Price rules' + ], 'class_name' => self::ADMIN_PRICE_RULES_CONTROLLER, - 'ParentClassName' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'parent_class_name' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, 'parent' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, 'module_tab' => true, 'visible' => true, ], [ - 'name' => $this->module->l('Products', self::FILE_NAME), + 'name' => [ + 'en' => 'Products' + ], 'class_name' => self::ADMIN_PRODUCTS_CONTROLLER, - 'ParentClassName' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'parent_class_name' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, 'parent' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, 'module_tab' => true, 'visible' => true, ], [ - 'name' => $this->module->l('Products availability', self::FILE_NAME), + 'name' => [ + 'en' => 'Products availability' + ], 'class_name' => self::ADMIN_PRODUCT_AVAILABILITY_CONTROLLER, - 'ParentClassName' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'parent_class_name' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, 'parent' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, 'module_tab' => true, 'visible' => false, ], [ - 'name' => $this->module->l('Zones', self::FILE_NAME), + 'name' => [ + 'en' => 'Zones' + ], 'class_name' => self::ADMIN_ZONES_CONTROLLER, - 'ParentClassName' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'parent_class_name' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, 'parent' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, 'module_tab' => true, 'visible' => true, ], [ - 'name' => $this->module->l('Shipment Settings', self::FILE_NAME), + 'name' => [ + 'en' => 'Shipment Settings' + ], 'class_name' => self::ADMIN_SHIPMENT_SETTINGS_CONTROLLER, - 'ParentClassName' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'parent_class_name' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, 'parent' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, 'module_tab' => true, 'visible' => true, ], [ - 'name' => $this->module->l('Basic Settings', self::FILE_NAME), + 'name' => [ + 'en' => 'Basic Settings' + ], 'class_name' => self::ADMIN_SETTINGS_CONTROLLER, - 'ParentClassName' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'parent_class_name' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, 'parent' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, 'module_tab' => true, 'visible' => true, ], [ - 'name' => $this->module->l('Import', self::FILE_NAME), + 'name' => [ + 'en' => 'Import' + ], 'class_name' => self::ADMIN_IMPORT_EXPORT_CONTROLLER, - 'ParentClassName' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'parent_class_name' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, 'parent' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, 'module_tab' => true, 'visible' => false, ], [ - 'name' => $this->module->l('Logs', self::FILE_NAME), + 'name' => [ + 'en' => 'Logs' + ], 'class_name' => self::ADMIN_LOGS_CONTROLLER, - 'ParentClassName' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'parent_class_name' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, 'parent' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, 'module_tab' => true, 'visible' => false, ], [ - 'name' => $this->module->l('Ajax', self::FILE_NAME), + 'name' => [ + 'en' => 'Ajax' + ], 'class_name' => self::ADMIN_AJAX_CONTROLLER, - 'ParentClassName' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'parent_class_name' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, 'parent' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, 'module_tab' => true, 'visible' => false, ], [ - 'name' => $this->module->l('Pudo Ajax', self::FILE_NAME), + 'name' => [ + 'en' => 'Pudo Ajax' + ], 'class_name' => self::ADMIN_PUDO_AJAX_CONTROLLER, - 'ParentClassName' => -1, + 'parent_class_name' => -1, 'module_tab' => true, 'visible' => false, ], [ - 'name' => $this->module->l('Request support', self::FILE_NAME), + 'name' => [ + 'en' => 'Request support' + ], 'class_name' => self::ADMIN_REQUEST_SUPPORT_CONTROLLER, - 'ParentClassName' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'parent_class_name' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, 'parent' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, 'module_tab' => true, 'visible' => false, ], [ - 'name' => $this->module->l('Shipment ajax', self::FILE_NAME), + 'name' => [ + 'en' => 'Shipment ajax' + ], 'class_name' => self::ADMIN_AJAX_SHIPMENTS_CONTROLLER, - 'ParentClassName' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, + 'parent_class_name' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, 'parent' => self::ADMIN_DPDBALTICS_MODULE_CONTROLLER, 'module_tab' => true, 'visible' => false, ], [ - 'name' => $this->module->l('Ajax on-board', self::FILE_NAME), + 'name' => [ + 'en' => 'Ajax on-board' + ], 'class_name' => self::ADMIN_AJAX_ON_BOARD_CONTROLLER, - 'ParentClassName' => -1, + 'parent_class_name' => -1, + 'visible' => false ], ]; } diff --git a/upgrade/Upgrade-3.2.16.php b/upgrade/Upgrade-3.2.16.php index ae4fa1cd..fc8a2ab2 100644 --- a/upgrade/Upgrade-3.2.16.php +++ b/upgrade/Upgrade-3.2.16.php @@ -10,8 +10,15 @@ * International Registered Trademark & Property of INVERTUS, UAB */ +use Invertus\dpdBaltics\Config\Config; +use Invertus\dpdBaltics\Factory\TabFactory; use Invertus\dpdBaltics\Infrastructure\Bootstrap\Install\ModuleTabInstaller; -use Invertus\dpdBaltics\Infrastructure\Bootstrap\Uninstall\ModuleTabUninstaller; +use Invertus\dpdBaltics\Install\Installer; +use Invertus\dpdBaltics\Provider\CurrentCountryProvider; +use Invertus\psModuleTabs\Object\Tab; +use Invertus\psModuleTabs\Object\TabsCollection; +use Invertus\psModuleTabs\Service\TabsInitializer; +use Invertus\psModuleTabs\Service\TabsInstaller; if (!defined('_PS_VERSION_')) { exit; @@ -19,23 +26,32 @@ /** * @return bool + * + * @throws PrestaShopDatabaseException + * @throws PrestaShopException */ function upgrade_module_3_2_16(DPDBaltics $module) { - /** @var ModuleTabUninstaller $moduleTabUninstaller */ - $moduleTabUninstaller = $module->getService(ModuleTabUninstaller::class); + $result = true; + + $dbQuery = new DbQuery(); + $dbQuery->select('id_tab'); + $dbQuery->from('tab'); + $dbQuery->where("`module` = '" . pSQL($module->name) . "'"); + $tabs = Db::getInstance()->executeS($dbQuery); + foreach ($tabs as $tab) { + $tabClass = new TabCore($tab['id_tab']); + $tabClass->delete(); + } /** @var ModuleTabInstaller $moduleTabInstaller */ $moduleTabInstaller = $module->getService(ModuleTabInstaller::class); - $result = true; - try { - $moduleTabUninstaller->init(); $moduleTabInstaller->init(); } catch (Exception $exception) { $result &= false; } return $result; -} +} \ No newline at end of file From 4484331c1f7b2cd36c6fab88b15cdd8d08400396 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Tue, 8 Aug 2023 13:16:14 +0300 Subject: [PATCH 05/20] changelog updated --- CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bee72ec8..aac37e5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -142,4 +142,10 @@ - Fixed module price rule and address tabs not opening. ## [3.2.15] -- Added possibility to change carrier for shipment from BO Order page before printing label even if Carrier is inactive in module. \ No newline at end of file +- Added possibility to change carrier for shipment from BO Order page before printing label even if Carrier is inactive in module. + +## [3.2.16] +- Shipping tab improvements. +- Improved PUDO orders with incorrect post code. +- Fixed BO bug then changing terminal. +- Improved module code base. From 6e358ca5dfb4688597cf0d648d7146e318d4eef0 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Tue, 8 Aug 2023 13:48:19 +0300 Subject: [PATCH 06/20] fixed module versioning to correct one --- CHANGELOG.md | 2 -- dpdbaltics.php | 2 +- upgrade/{Upgrade-3.2.16.php => Upgrade-3.2.15.php} | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) rename upgrade/{Upgrade-3.2.16.php => Upgrade-3.2.15.php} (96%) diff --git a/CHANGELOG.md b/CHANGELOG.md index aac37e5e..0d3a3ec2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -143,8 +143,6 @@ ## [3.2.15] - Added possibility to change carrier for shipment from BO Order page before printing label even if Carrier is inactive in module. - -## [3.2.16] - Shipping tab improvements. - Improved PUDO orders with incorrect post code. - Fixed BO bug then changing terminal. diff --git a/dpdbaltics.php b/dpdbaltics.php index 2eb1fa65..f9184905 100644 --- a/dpdbaltics.php +++ b/dpdbaltics.php @@ -92,7 +92,7 @@ public function __construct() $this->author = 'Invertus'; $this->tab = 'shipping_logistics'; $this->description = 'DPD Baltics shipping integration'; - $this->version = '3.2.16'; + $this->version = '3.2.15'; $this->ps_versions_compliancy = ['min' => '1.7.1.0', 'max' => _PS_VERSION_]; $this->need_instance = 0; parent::__construct(); diff --git a/upgrade/Upgrade-3.2.16.php b/upgrade/Upgrade-3.2.15.php similarity index 96% rename from upgrade/Upgrade-3.2.16.php rename to upgrade/Upgrade-3.2.15.php index fc8a2ab2..13972145 100644 --- a/upgrade/Upgrade-3.2.16.php +++ b/upgrade/Upgrade-3.2.15.php @@ -30,7 +30,7 @@ * @throws PrestaShopDatabaseException * @throws PrestaShopException */ -function upgrade_module_3_2_16(DPDBaltics $module) +function upgrade_module_3_2_15(DPDBaltics $module) { $result = true; From 29cba58ea5c2cd47b46b3da8d749dc5461d8aa8a Mon Sep 17 00:00:00 2001 From: Gytautas Date: Fri, 8 Sep 2023 09:24:06 +0300 Subject: [PATCH 07/20] service fix --- src/Entity/DPDPriceRule.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Entity/DPDPriceRule.php b/src/Entity/DPDPriceRule.php index 8d3127a8..889354ad 100644 --- a/src/Entity/DPDPriceRule.php +++ b/src/Entity/DPDPriceRule.php @@ -258,7 +258,7 @@ public function isApplicableByAddress(Address $address) $module = Module::getInstanceByName('dpdbaltics'); /** @var ZoneRepository $zoneRepo */ - $zoneRepo = $module->getModuleContainer()->get('invertus.dpdbaltics.repository.dpdzone_repository'); + $zoneRepo = $module->getModuleContainer()->get('invertus.dpdbaltics.repository.zone_repository'); return $zoneRepo->findZoneInRangeByAddress($address); } From c1de31c1871d9de85941ca8e764f6e5dde856efb Mon Sep 17 00:00:00 2001 From: Gytautas Date: Thu, 21 Sep 2023 17:10:37 +0300 Subject: [PATCH 08/20] fix: added additional validation if company name is empty --- src/Service/API/ShipmentApiService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Service/API/ShipmentApiService.php b/src/Service/API/ShipmentApiService.php index aca8034f..b1e1da1b 100644 --- a/src/Service/API/ShipmentApiService.php +++ b/src/Service/API/ShipmentApiService.php @@ -90,7 +90,7 @@ public function __construct( public function createShipment($addressId, ShipmentData $shipmentData, $orderId) { $address = new Address($addressId); - $isCompany = $shipmentData->getCompany() ? true : false; + $isCompany = trim($shipmentData->getCompany()) ? true : false; //todo $firstName = $shipmentData->getName(); if ($isCompany) { $firstName = $shipmentData->getCompany(); From 15d88fbd68db3babc2ff9b4d8836453209b88f6d Mon Sep 17 00:00:00 2001 From: Gytautas Date: Thu, 21 Sep 2023 17:13:44 +0300 Subject: [PATCH 09/20] fix: comment deleted --- src/Service/API/ShipmentApiService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Service/API/ShipmentApiService.php b/src/Service/API/ShipmentApiService.php index b1e1da1b..84b14897 100644 --- a/src/Service/API/ShipmentApiService.php +++ b/src/Service/API/ShipmentApiService.php @@ -90,7 +90,7 @@ public function __construct( public function createShipment($addressId, ShipmentData $shipmentData, $orderId) { $address = new Address($addressId); - $isCompany = trim($shipmentData->getCompany()) ? true : false; //todo + $isCompany = trim($shipmentData->getCompany()) ? true : false; $firstName = $shipmentData->getName(); if ($isCompany) { $firstName = $shipmentData->getCompany(); From 28d7f6ccafc9a7759b4063a551d7db045901ab7c Mon Sep 17 00:00:00 2001 From: Gytautas Date: Tue, 17 Oct 2023 10:30:09 +0300 Subject: [PATCH 10/20] fix: comment deleted --- src/Service/API/ShipmentApiService.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Service/API/ShipmentApiService.php b/src/Service/API/ShipmentApiService.php index 84b14897..ef125a9c 100644 --- a/src/Service/API/ShipmentApiService.php +++ b/src/Service/API/ShipmentApiService.php @@ -90,6 +90,7 @@ public function __construct( public function createShipment($addressId, ShipmentData $shipmentData, $orderId) { $address = new Address($addressId); + $isCompany = trim($shipmentData->getCompany()) ? true : false; $firstName = $shipmentData->getName(); if ($isCompany) { From 8bc5f040375d74b059a8c8d5c8a0caffd3e3101e Mon Sep 17 00:00:00 2001 From: Gytautas Date: Tue, 17 Oct 2023 14:41:39 +0300 Subject: [PATCH 11/20] fix: fixed price rules as previously they was never exist --- src/Service/PriceRuleService.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Service/PriceRuleService.php b/src/Service/PriceRuleService.php index fabbfef2..9c9e4778 100644 --- a/src/Service/PriceRuleService.php +++ b/src/Service/PriceRuleService.php @@ -392,8 +392,12 @@ public function applyPriceRuleForCarrier(Cart $cart, $priceRulesIds, $shopId) { $availablePriceRules = $this->priceRuleRepository->findAllAvailableInShop($shopId); + if (!$availablePriceRules) { + return false; + } + foreach ($priceRulesIds as $priceRuleId) { - if (!in_array($priceRuleId, $availablePriceRules)) { + if (!$this->doesCarrierHavePriceRule($priceRuleId, $availablePriceRules)) { return false; } @@ -429,4 +433,20 @@ private function duplicatePriceRuleTablesData($tables, $priceRuleTablesData, $ne return true; } + + /** + * @param string $priceRuleId + * @param array|false $availablePriceRules + * @return bool + */ + private function doesCarrierHavePriceRule($priceRuleId, $availablePriceRules) + { + foreach ($availablePriceRules as $rule) { + if (isset($rule['id_dpd_price_rule']) && $rule['id_dpd_price_rule'] === $priceRuleId) { + return true; + } + } + + return false; + } } From de0b88333535230d8724025e5149b82cfde83a7a Mon Sep 17 00:00:00 2001 From: Gytautas Date: Tue, 17 Oct 2023 14:55:04 +0300 Subject: [PATCH 12/20] fix: casted values into integer --- src/Service/PriceRuleService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Service/PriceRuleService.php b/src/Service/PriceRuleService.php index 9c9e4778..7ac5d33e 100644 --- a/src/Service/PriceRuleService.php +++ b/src/Service/PriceRuleService.php @@ -442,7 +442,7 @@ private function duplicatePriceRuleTablesData($tables, $priceRuleTablesData, $ne private function doesCarrierHavePriceRule($priceRuleId, $availablePriceRules) { foreach ($availablePriceRules as $rule) { - if (isset($rule['id_dpd_price_rule']) && $rule['id_dpd_price_rule'] === $priceRuleId) { + if (isset($rule['id_dpd_price_rule']) && (int) $rule['id_dpd_price_rule'] === (int) $priceRuleId) { return true; } } From 1987714a8963681763f3081534ccb63d447e2c42 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Tue, 17 Oct 2023 14:58:28 +0300 Subject: [PATCH 13/20] renamed method to be more clear --- src/Service/PriceRuleService.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Service/PriceRuleService.php b/src/Service/PriceRuleService.php index 7ac5d33e..b23bbc91 100644 --- a/src/Service/PriceRuleService.php +++ b/src/Service/PriceRuleService.php @@ -397,7 +397,7 @@ public function applyPriceRuleForCarrier(Cart $cart, $priceRulesIds, $shopId) } foreach ($priceRulesIds as $priceRuleId) { - if (!$this->doesCarrierHavePriceRule($priceRuleId, $availablePriceRules)) { + if (!$this->ensureCarrierHasPriceRule($priceRuleId, $availablePriceRules)) { return false; } @@ -439,7 +439,7 @@ private function duplicatePriceRuleTablesData($tables, $priceRuleTablesData, $ne * @param array|false $availablePriceRules * @return bool */ - private function doesCarrierHavePriceRule($priceRuleId, $availablePriceRules) + private function ensureCarrierHasPriceRule($priceRuleId, $availablePriceRules) { foreach ($availablePriceRules as $rule) { if (isset($rule['id_dpd_price_rule']) && (int) $rule['id_dpd_price_rule'] === (int) $priceRuleId) { From 7aed46ca77fd98273ce29ba4bfac06a07ae7cdad Mon Sep 17 00:00:00 2001 From: Gytautas Date: Mon, 27 Nov 2023 16:03:25 +0200 Subject: [PATCH 14/20] fix: label printix fix --- src/Service/PudoService.php | 3 ++- src/Service/ShipmentService.php | 3 ++- views/templates/hook/admin/partials/pudo-info.tpl | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Service/PudoService.php b/src/Service/PudoService.php index a3fb14e3..6e59cd97 100644 --- a/src/Service/PudoService.php +++ b/src/Service/PudoService.php @@ -241,7 +241,7 @@ public function searchPudoServices($city, $carrierId, $cartId) ]; } - public function savePudoOrder($productId, $pudoId, $isoCode, $cartId, $city, $street) + public function savePudoOrder($productId, $pudoId, $isoCode, $cartId, $city, $street, $zipCode) { $pudoOrderId = $this->pudoRepository->getIdByCart($cartId); $product = new DPDProduct($productId); @@ -254,6 +254,7 @@ public function savePudoOrder($productId, $pudoId, $isoCode, $cartId, $city, $st $pudoOrder->id_cart = $cartId; $pudoOrder->city = $city; $pudoOrder->street = $street; + $pudoOrder->post_code = $zipCode; $pudoOrder->save(); } diff --git a/src/Service/ShipmentService.php b/src/Service/ShipmentService.php index b75d09b8..ffe9dcc6 100644 --- a/src/Service/ShipmentService.php +++ b/src/Service/ShipmentService.php @@ -415,9 +415,10 @@ public function saveShipment(Order $order, ShipmentData $shipmentData, $print = $isoCode = $shipmentData->getSelectedPudoIsoCode(); $city = $shipmentData->getCity(); $street = $shipmentData->getDpdStreet(); + $zipCode = $shipmentData->getDpdZipCode(); try { - $this->pudoService->savePudoOrder($productId, $pudoId, $isoCode, $cartId, $city, $street); + $this->pudoService->savePudoOrder($productId, $pudoId, $isoCode, $cartId, $city, $street, $zipCode); } catch (Exception $e) { $response['message'] = $this->module->l( sprintf('Failed to save pudo order to database Error: %s', $e->getMessage(). 'ID cart: '. $order->id_cart) diff --git a/views/templates/hook/admin/partials/pudo-info.tpl b/views/templates/hook/admin/partials/pudo-info.tpl index 3bce6f6f..4f09ab78 100644 --- a/views/templates/hook/admin/partials/pudo-info.tpl +++ b/views/templates/hook/admin/partials/pudo-info.tpl @@ -26,12 +26,15 @@
{$selectedPudo->getStreet()}
+ +
{$selectedPudo->getPCode()}
+
From d39cca340bc753e41392b51cca564d6351076dc7 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Mon, 27 Nov 2023 16:26:04 +0200 Subject: [PATCH 15/20] fix: added some more validations to make sure street exist --- src/Factory/ShipmentDataFactory.php | 1 + src/Service/API/ShipmentApiService.php | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Factory/ShipmentDataFactory.php b/src/Factory/ShipmentDataFactory.php index 68552708..28b59341 100644 --- a/src/Factory/ShipmentDataFactory.php +++ b/src/Factory/ShipmentDataFactory.php @@ -120,6 +120,7 @@ public function getShipmentDataByIdOrder($orderId) $shipmentData->setDpdCountry($dpdPudo->country_code); $shipmentData->setSelectedPudoIsoCode($dpdPudo->country_code); $shipmentData->setDpdZipCode($address->postcode); + $shipmentData->setDpdStreet($dpdPudo->street); $shipmentData->setSelectedPudoId($dpdPudo->pudo_id); } diff --git a/src/Service/API/ShipmentApiService.php b/src/Service/API/ShipmentApiService.php index ef125a9c..3b2e5e7f 100644 --- a/src/Service/API/ShipmentApiService.php +++ b/src/Service/API/ShipmentApiService.php @@ -237,6 +237,7 @@ private function setNotRequiredData(ShipmentCreationRequest $shipmentCreationReq private function setPudoData(ShipmentCreationRequest $shipmentCreationRequest, ShipmentData $shipmentData) { $shipmentCreationRequest->setParcelShopId($shipmentData->getSelectedPudoId()); + $shipmentCreationRequest->setStreet($shipmentData->getDpdStreet()); return $shipmentCreationRequest; } From f634b5167e673ed77b9c186da1bf5d80df830700 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Mon, 27 Nov 2023 16:28:09 +0200 Subject: [PATCH 16/20] removed div --- views/templates/hook/admin/partials/pudo-info.tpl | 1 - 1 file changed, 1 deletion(-) diff --git a/views/templates/hook/admin/partials/pudo-info.tpl b/views/templates/hook/admin/partials/pudo-info.tpl index 4f09ab78..e8aa7626 100644 --- a/views/templates/hook/admin/partials/pudo-info.tpl +++ b/views/templates/hook/admin/partials/pudo-info.tpl @@ -27,7 +27,6 @@ {$selectedPudo->getStreet()}
-
From 7e32d7d0f6ad6246783545c7f9878e2077401cc7 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Mon, 27 Nov 2023 16:47:02 +0200 Subject: [PATCH 17/20] version increase --- CHANGELOG.md | 3 +++ dpdbaltics.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49341cd7..a2a029cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -151,3 +151,6 @@ ## [3.2.16] - Improved performance - Added additional validation + +## [3.2.17] +- Label printing bug fix diff --git a/dpdbaltics.php b/dpdbaltics.php index 0fe045a9..cb11ea4f 100644 --- a/dpdbaltics.php +++ b/dpdbaltics.php @@ -92,7 +92,7 @@ public function __construct() $this->author = 'Invertus'; $this->tab = 'shipping_logistics'; $this->description = 'DPD Baltics shipping integration'; - $this->version = '3.2.16'; + $this->version = '3.2.17'; $this->ps_versions_compliancy = ['min' => '1.7.1.0', 'max' => _PS_VERSION_]; $this->need_instance = 0; parent::__construct(); From d7522d0ea7c87744c0b77923021d4eed8ed514d4 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Mon, 27 Nov 2023 16:48:34 +0200 Subject: [PATCH 18/20] changelog typo fix --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2a029cf..b3168040 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -153,4 +153,4 @@ - Added additional validation ## [3.2.17] -- Label printing bug fix +- Label printing after changing shipment product bug fix From 5308142ad53497aa6256a573057281550e6cf83a Mon Sep 17 00:00:00 2001 From: Gytautas Date: Tue, 28 Nov 2023 14:26:56 +0200 Subject: [PATCH 19/20] fix: street setter bug fix --- src/Service/API/ShipmentApiService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Service/API/ShipmentApiService.php b/src/Service/API/ShipmentApiService.php index 3b2e5e7f..9c40edbe 100644 --- a/src/Service/API/ShipmentApiService.php +++ b/src/Service/API/ShipmentApiService.php @@ -108,6 +108,7 @@ public function createShipment($addressId, ShipmentData $shipmentData, $orderId) $parcel = $this->parcelShopService->getParcelShopByShopId($shipmentData->getSelectedPudoId()); $selectedParcel = is_array($parcel) ? reset($parcel) : $parcel; $postCode = $selectedParcel->getPCode(); + $address->address1 = $selectedParcel->getStreet(); } // IF prestashop allows, we take selected parcel terminal address in case information is missing in checkout address in specific cases. @@ -237,7 +238,6 @@ private function setNotRequiredData(ShipmentCreationRequest $shipmentCreationReq private function setPudoData(ShipmentCreationRequest $shipmentCreationRequest, ShipmentData $shipmentData) { $shipmentCreationRequest->setParcelShopId($shipmentData->getSelectedPudoId()); - $shipmentCreationRequest->setStreet($shipmentData->getDpdStreet()); return $shipmentCreationRequest; } From 0d7356e37ba962833fc64cae843ada5083342ade Mon Sep 17 00:00:00 2001 From: Gytautas Date: Wed, 29 Nov 2023 14:31:47 +0200 Subject: [PATCH 20/20] escaped variables --- .../hook/admin/partials/pudo-info.tpl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/views/templates/hook/admin/partials/pudo-info.tpl b/views/templates/hook/admin/partials/pudo-info.tpl index e8aa7626..100d4934 100644 --- a/views/templates/hook/admin/partials/pudo-info.tpl +++ b/views/templates/hook/admin/partials/pudo-info.tpl @@ -17,34 +17,34 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 *}
- - + +
- {$selectedPudo->getStreet()} + {$selectedPudo->getStreet()|escape:'htmlall':'UTF-8'}
- +
- {$selectedPudo->getPCode()} + {$selectedPudo->getPCode()|escape:'htmlall':'UTF-8'}
- +
- {$selectedPudo->getCity()} + {$selectedPudo->getCity()|escape:'htmlall':'UTF-8'}
- {$selectedPudo->getCountry()} + {$selectedPudo->getCountry()|escape:'htmlall':'UTF-8'}
@@ -61,7 +61,7 @@