Add InPost Pay integration to admin templates
- Created a new template for the cart rule form with custom label, switch, and choice widgets. - Implemented the InPost Pay block in the order details template for displaying delivery method, APM, and VAT invoice request. - Added legacy support for the order details template to maintain compatibility with older PrestaShop versions.
This commit is contained in:
8
.vscode/ftp-kr.sync.cache.json
vendored
8
.vscode/ftp-kr.sync.cache.json
vendored
@@ -7377,8 +7377,8 @@
|
||||
},
|
||||
"front.tpl": {
|
||||
"type": "-",
|
||||
"size": 19601,
|
||||
"lmtime": 1754338438943,
|
||||
"size": 19705,
|
||||
"lmtime": 1757443703631,
|
||||
"modified": false
|
||||
},
|
||||
"index.php": {
|
||||
@@ -14072,8 +14072,8 @@
|
||||
},
|
||||
"ps_shoppingcart.tpl": {
|
||||
"type": "-",
|
||||
"size": 19416,
|
||||
"lmtime": 1755850704059,
|
||||
"size": 19544,
|
||||
"lmtime": 1757443628303,
|
||||
"modified": false
|
||||
}
|
||||
},
|
||||
|
||||
65
modules/inpostizi/config/admin/services.yml
Normal file
65
modules/inpostizi/config/admin/services.yml
Normal file
@@ -0,0 +1,65 @@
|
||||
# PS >= 1.7.4 BO configuration
|
||||
imports:
|
||||
- { resource: ../services/sf34.yml }
|
||||
- { resource: ../services/common_admin.yml }
|
||||
|
||||
parameters:
|
||||
container.autowiring.strict_mode: true
|
||||
|
||||
services:
|
||||
_defaults:
|
||||
public: false
|
||||
autowire: true
|
||||
bind:
|
||||
$context: '@inpost.izi.context'
|
||||
$assetsProviders: !tagged inpost.izi.admin_assets_provider
|
||||
$formFactory: '@=container.has("form.factory") ? service("form.factory") : service("inpost.izi.form_factory")'
|
||||
|
||||
izi\prestashop\Hook\Admin\ActionAdminCartRuleSaveAfter:
|
||||
class: izi\prestashop\Hook\Admin\ActionAdminCartRuleSaveAfter
|
||||
|
||||
izi\prestashop\Hook\Admin\ActionAdminControllerSetMedia:
|
||||
class: izi\prestashop\Hook\Admin\ActionAdminControllerSetMedia
|
||||
|
||||
izi\prestashop\Hook\Admin\ActionAdminInPostConfirmedShipmentsControllerAfter:
|
||||
class: izi\prestashop\Hook\Admin\ActionAdminInPostConfirmedShipmentsControllerAfter
|
||||
|
||||
izi\prestashop\Hook\Admin\ActionAdminInPostConfirmedShipmentsControllerBefore:
|
||||
class: izi\prestashop\Hook\Admin\ActionAdminInPostConfirmedShipmentsControllerBefore
|
||||
|
||||
izi\prestashop\Hook\Admin\DisplayAdminOrderSide:
|
||||
class: izi\prestashop\Hook\Admin\DisplayAdminOrderSide
|
||||
|
||||
izi\prestashop\Hook\Admin\DisplayAdminOrderLeft:
|
||||
class: izi\prestashop\Hook\Admin\DisplayAdminOrderLeft
|
||||
|
||||
izi\prestashop\Hook\Admin\DisplayBackOfficeHeader:
|
||||
class: izi\prestashop\Hook\Admin\DisplayBackOfficeHeader
|
||||
|
||||
izi\prestashop\CommandBus:
|
||||
class: izi\prestashop\CommandBus
|
||||
tags: [ container.service_subscriber ]
|
||||
|
||||
izi\prestashop\Hook\HookExecutor:
|
||||
class: izi\prestashop\Hook\HookExecutor
|
||||
tags: [ container.service_subscriber ]
|
||||
arguments:
|
||||
$widget: '@inpost.izi.module'
|
||||
|
||||
izi\prestashop\Form\FormFactoryFactory:
|
||||
class: izi\prestashop\Form\FormFactoryFactory
|
||||
|
||||
inpost.izi.form_factory:
|
||||
class: Symfony\Component\Form\FormFactoryInterface
|
||||
factory: [ '@izi\prestashop\Form\FormFactoryFactory', create ]
|
||||
arguments:
|
||||
- '@inpost.izi.form_type_locator'
|
||||
- Symfony\Component\Form\Extension\Core\Type\FormType: ['@izi\prestashop\Form\TypeExtension\HelpTextExtension']
|
||||
|
||||
inpost.izi.form_type_locator:
|
||||
class: Symfony\Component\DependencyInjection\ServiceLocator
|
||||
tags:
|
||||
- { name: container.service_locator }
|
||||
arguments:
|
||||
- izi\prestashop\Form\Type\CartRuleOptionsType: '@izi\prestashop\Form\Type\CartRuleOptionsType'
|
||||
izi\prestashop\Form\Type\ObjectModelType: '@izi\prestashop\Form\Type\ObjectModelType'
|
||||
100
modules/inpostizi/config/front/services.yml
Normal file
100
modules/inpostizi/config/front/services.yml
Normal file
@@ -0,0 +1,100 @@
|
||||
# PS >= 1.7.4 FO configuration
|
||||
imports:
|
||||
- { resource: ../services/sf34.yml }
|
||||
- { resource: ../services/common_front.yml }
|
||||
|
||||
services:
|
||||
_defaults:
|
||||
public: false
|
||||
|
||||
inpost.izi.hook_locator:
|
||||
class: Symfony\Component\DependencyInjection\ServiceLocator
|
||||
tags: [ container.service_locator ]
|
||||
arguments:
|
||||
- actionObjectCartDeleteBefore: '@izi\prestashop\Hook\Common\ActionCartDeleteBefore'
|
||||
actionObjectCartUpdateAfter: '@izi\prestashop\Hook\Common\ActionCartUpdateAfter'
|
||||
actionObjectInPostShipmentModelAddAfter: '@izi\prestashop\Hook\Common\ActionShipmentAddAfter'
|
||||
actionObjectInPostShipmentModelUpdateBefore: '@izi\prestashop\Hook\Common\ActionShipmentUpdateBefore'
|
||||
actionObjectInPostShipmentModelUpdateAfter: '@izi\prestashop\Hook\Common\ActionShipmentUpdateAfter'
|
||||
actionValidateOrder: '@izi\prestashop\Hook\Common\ActionValidateOrder'
|
||||
actionOrderStatusPostUpdate: '@izi\prestashop\Hook\Common\ActionOrderStatusPostUpdate'
|
||||
actionObjectOrderUpdateBefore: '@izi\prestashop\Hook\Common\ActionObjectOrderUpdateBefore'
|
||||
actionObjectOrderUpdateAfter: '@izi\prestashop\Hook\Common\ActionObjectOrderUpdateAfter'
|
||||
actionAjaxDieCartControllerdisplayAjaxUpdateBefore: '@izi\prestashop\Hook\Front\ActionCartControllerAjaxUpdateResponse'
|
||||
actionFrontControllerSetMedia: '@izi\prestashop\Hook\Front\ActionFrontControllerSetMedia'
|
||||
actionEmailSendBefore: '@izi\prestashop\Hook\Common\ActionEmailSendBefore'
|
||||
displayHeader: '@izi\prestashop\Hook\Front\DisplayHeader'
|
||||
paymentOptions: '@izi\prestashop\Hook\Front\ActionGetPaymentOptions'
|
||||
displayOrderConfirmation: '@izi\prestashop\Hook\Front\DisplayOrderConfirmation'
|
||||
displayIziThankYou: '@izi\prestashop\Hook\Front\DisplayIziThankYou'
|
||||
displayPaymentReturn: '@izi\prestashop\Hook\Front\DisplayPaymentReturn'
|
||||
displayProductActions: '@izi\prestashop\Hook\Front\DisplayProductActions'
|
||||
displayProductAdditionalInfo: '@izi\prestashop\Hook\Front\DisplayProductAdditionalInfo'
|
||||
displayExpressCheckout: '@izi\prestashop\Hook\Front\DisplayExpressCheckout'
|
||||
displayShoppingCart: '@izi\prestashop\Hook\Front\DisplayShoppingCart'
|
||||
displayShoppingCartFooter: '@izi\prestashop\Hook\Front\DisplayShoppingCartFooter'
|
||||
displayCheckoutSummaryTop: '@izi\prestashop\Hook\Front\DisplayCheckoutSummaryTop'
|
||||
displayCustomerAccountFormTop: '@izi\prestashop\Hook\Front\DisplayCustomerAccountFormTop'
|
||||
displayCustomerLoginFormAfter: '@izi\prestashop\Hook\Front\DisplayCustomerLoginFormAfter'
|
||||
displayIziCartPreviewButton: '@izi\prestashop\Hook\Front\DisplayIziCartPreviewButton'
|
||||
displayIziCheckoutButton: '@izi\prestashop\Hook\Front\DisplayIziCheckoutButton'
|
||||
# products
|
||||
actionObjectProductDeleteBefore: '@izi\prestashop\Hook\Common\Product\ActionProductDeleteBefore'
|
||||
actionObjectProductDeleteAfter: '@izi\prestashop\Hook\Common\Product\ActionProductDeleteAfter'
|
||||
actionObjectProductUpdateAfter: '@izi\prestashop\Hook\Common\Product\ActionProductUpdateAfter'
|
||||
actionObjectCombinationDeleteBefore: '@izi\prestashop\Hook\Common\Product\ActionCombinationDeleteBefore'
|
||||
actionObjectCombinationDeleteAfter: '@izi\prestashop\Hook\Common\Product\ActionCombinationDeleteAfter'
|
||||
actionObjectCombinationUpdateAfter: '@izi\prestashop\Hook\Common\Product\ActionCombinationUpdateAfter'
|
||||
actionObjectImageAddAfter: '@izi\prestashop\Hook\Common\Product\ActionImageAddAfter'
|
||||
actionObjectImageDeleteAfter: '@izi\prestashop\Hook\Common\Product\ActionImageDeleteAfter'
|
||||
actionObjectSpecificPriceAddAfter: '@izi\prestashop\Hook\Common\Product\ActionSpecificPriceAddAfter'
|
||||
actionObjectSpecificPriceUpdateAfter: '@izi\prestashop\Hook\Common\Product\ActionSpecificPriceUpdateAfter'
|
||||
actionObjectSpecificPriceDeleteAfter: '@izi\prestashop\Hook\Common\Product\ActionSpecificPriceDeleteAfter'
|
||||
actionUpdateQuantity: '@izi\prestashop\Hook\Common\Product\ActionUpdateQuantity'
|
||||
|
||||
inpost.izi.basket_event_handler_locator:
|
||||
class: Symfony\Component\DependencyInjection\ServiceLocator
|
||||
tags: [ container.service_locator ]
|
||||
arguments:
|
||||
- PRODUCTS_QUANTITY: '@izi\prestashop\MerchantApi\Handler\Basket\ProductsQuantityEventHandler'
|
||||
PROMO_CODES: '@izi\prestashop\MerchantApi\Handler\Basket\PromoCodesEventHandler'
|
||||
RELATED_PRODUCTS: '@izi\prestashop\MerchantApi\Handler\Basket\RelatedProductsEventHandler'
|
||||
|
||||
izi\prestashop\CommandBus:
|
||||
class: izi\prestashop\CommandBus
|
||||
arguments:
|
||||
- '@inpost.izi.command_handler_locator'
|
||||
|
||||
inpost.izi.command_handler_locator:
|
||||
class: Symfony\Component\DependencyInjection\ServiceLocator
|
||||
tags: [ container.service_locator ]
|
||||
arguments:
|
||||
- izi\prestashop\Command\UnbindBasketCommand: '@izi\prestashop\Handler\UnbindBasketHandlerInterface'
|
||||
izi\prestashop\Command\UpdateOrderTrackingNumbersCommand: '@izi\prestashop\Handler\UpdateOrderTrackingNumbersHandlerInterface'
|
||||
izi\prestashop\Command\UpdateOrderStatusCommand: '@izi\prestashop\Handler\UpdateOrderStatusHandlerInterface'
|
||||
izi\prestashop\Command\UpdateOrderAddressDeliveryCommand: '@izi\prestashop\Handler\UpdateOrderAddressDeliveryHandlerInterface'
|
||||
izi\prestashop\Command\UpdateBasketCommand: '@izi\prestashop\Handler\UpdateBasketHandlerInterface'
|
||||
izi\prestashop\Command\GetBasketBindingKeyCommand: '@izi\prestashop\Handler\GetBasketBindingKeyHandlerInterface'
|
||||
izi\prestashop\Command\GetOrderConfirmationUrlCommand: '@izi\prestashop\Handler\GetOrderConfirmationUrlHandlerInterface'
|
||||
izi\prestashop\MerchantApi\Command\ConfirmBasketBindingCommand: '@izi\prestashop\MerchantApi\Handler\ConfirmBasketBindingHandlerInterface'
|
||||
izi\prestashop\MerchantApi\Command\DeleteBasketBindingCommand: '@izi\prestashop\MerchantApi\Handler\DeleteBasketBindingHandlerInterface'
|
||||
izi\prestashop\MerchantApi\Command\GetBasketCommand: '@izi\prestashop\MerchantApi\Handler\GetBasketHandlerInterface'
|
||||
izi\prestashop\MerchantApi\Command\UpdateBasketCommand: '@izi\prestashop\MerchantApi\Handler\UpdateBasketHandlerInterface'
|
||||
izi\prestashop\MerchantApi\Command\GetProductsCommand: '@izi\prestashop\MerchantApi\Handler\GetProductsHandlerInterface'
|
||||
izi\prestashop\MerchantApi\Command\AddProductToBasketCommand: '@izi\prestashop\MerchantApi\Handler\AddProductToBasketHandlerInterface'
|
||||
izi\prestashop\MerchantApi\Command\CreateOrderCommand: '@izi\prestashop\MerchantApi\Handler\CreateOrderHandlerInterface'
|
||||
izi\prestashop\MerchantApi\Command\GetOrderCommand: '@izi\prestashop\MerchantApi\Handler\GetOrderHandlerInterface'
|
||||
izi\prestashop\MerchantApi\Command\UpdateOrderCommand: '@izi\prestashop\MerchantApi\Handler\UpdateOrderHandlerInterface'
|
||||
izi\prestashop\MerchantApi\Command\Basket\CreateCartCommand: '@izi\prestashop\MerchantApi\Handler\Basket\CreateCartHandlerInterface'
|
||||
izi\prestashop\MerchantApi\Command\Basket\AddProductToCartCommand: '@izi\prestashop\MerchantApi\Handler\Basket\AddProductToCartHandlerInterface'
|
||||
izi\prestashop\MerchantApi\Command\Basket\IncrementCartQuantityCommand: '@izi\prestashop\MerchantApi\Handler\Basket\IncrementCartQuantityHandlerInterface'
|
||||
izi\prestashop\MerchantApi\Command\Order\UpdateCartMessageCommand: '@izi\prestashop\MerchantApi\Handler\Order\UpdateCartMessageHandlerInterface'
|
||||
izi\prestashop\HotProduct\Message\DeleteRemoteProductCommand: '@izi\prestashop\HotProduct\MessageHandler\DeleteRemoteProductHandlerInterface'
|
||||
izi\prestashop\HotProduct\Message\UpdateHotProductCommand: '@izi\prestashop\HotProduct\MessageHandler\UpdateHotProductHandlerInterface'
|
||||
izi\prestashop\Analytics\Command\UpdateCartAnalyticsCommand: '@izi\prestashop\Analytics\Handler\UpdateCartAnalyticsHandlerInterface'
|
||||
|
||||
inpost.izi.widget_controller_locator:
|
||||
class: Symfony\Component\DependencyInjection\ServiceLocator
|
||||
tags: [ container.service_locator ]
|
||||
arguments:
|
||||
- Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface: '@inpost.izi.security.authorization_checker'
|
||||
4
modules/inpostizi/config/routes.yml
Normal file
4
modules/inpostizi/config/routes.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
inpost_izi_admin:
|
||||
resource: ../src/Controller/Admin
|
||||
type: annotation
|
||||
prefix: /inpost/izi
|
||||
632
modules/inpostizi/config/services.yml
Normal file
632
modules/inpostizi/config/services.yml
Normal file
@@ -0,0 +1,632 @@
|
||||
# config page configuration
|
||||
imports:
|
||||
- { resource: services/common.yml }
|
||||
- { resource: services/common_admin.yml }
|
||||
|
||||
services:
|
||||
izi\prestashop\CommandBus:
|
||||
class: izi\prestashop\CommandBus
|
||||
public: false
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: container.service_subscriber }
|
||||
|
||||
izi\prestashop\Controller\Admin\ConfigurationController:
|
||||
class: izi\prestashop\Controller\Admin\ConfigurationController
|
||||
public: false
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: controller.service_arguments }
|
||||
- { name: container.service_subscriber }
|
||||
arguments:
|
||||
- '@izi\prestashop\Translation\LegacyTranslator'
|
||||
- '@inpost.izi.context'
|
||||
- !tagged inpost.izi.config_initializer
|
||||
- '@izi\prestashop\Configuration\ApiConfigurationInterface'
|
||||
- '%kernel.debug%'
|
||||
calls:
|
||||
- { method: setLogger, arguments: [ '@inpost.izi.general_logger' ] }
|
||||
|
||||
izi\prestashop\Controller\Admin\HotProductController:
|
||||
class: izi\prestashop\Controller\Admin\HotProductController
|
||||
public: false
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: controller.service_arguments }
|
||||
- { name: container.service_subscriber }
|
||||
arguments:
|
||||
- '@inpost.izi.shop_context'
|
||||
- '@izi\prestashop\Translation\LegacyTranslator'
|
||||
- '@inpost.izi.context'
|
||||
- '@izi\prestashop\Configuration\ApiConfigurationInterface'
|
||||
- !tagged inpost.izi.config_initializer
|
||||
- '%kernel.debug%'
|
||||
calls:
|
||||
- { method: setLogger, arguments: [ '@inpost.izi.general_logger' ] }
|
||||
|
||||
izi\prestashop\Form\Type\GeneralConfigurationType:
|
||||
class: izi\prestashop\Form\Type\GeneralConfigurationType
|
||||
tags:
|
||||
- { name: form.type }
|
||||
arguments:
|
||||
- '@izi\prestashop\Translation\LegacyTranslator'
|
||||
- '@izi\prestashop\Event\EventDispatcherInterface'
|
||||
|
||||
izi\prestashop\Form\Type\ApiConfigurationType:
|
||||
class: izi\prestashop\Form\Type\ApiConfigurationType
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: form.type }
|
||||
|
||||
izi\prestashop\Form\Type\EnvironmentChoiceType:
|
||||
class: izi\prestashop\Form\Type\EnvironmentChoiceType
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: form.type }
|
||||
|
||||
izi\prestashop\Form\Type\ClientCredentialsType:
|
||||
class: izi\prestashop\Form\Type\ClientCredentialsType
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: form.type }
|
||||
|
||||
izi\prestashop\Form\Type\MaskedPasswordType:
|
||||
class: izi\prestashop\Form\Type\MaskedPasswordType
|
||||
tags:
|
||||
- { name: form.type }
|
||||
|
||||
izi\prestashop\Form\Type\OrdersConfigurationType:
|
||||
class: izi\prestashop\Form\Type\OrdersConfigurationType
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: form.type }
|
||||
|
||||
izi\prestashop\Form\Type\OrderStateChoiceType:
|
||||
class: izi\prestashop\Form\Type\OrderStateChoiceType
|
||||
tags:
|
||||
- { name: form.type }
|
||||
arguments:
|
||||
- '@inpost.izi.context'
|
||||
- '@izi\prestashop\Form\ChoiceList\OrderStateChoiceLoader'
|
||||
|
||||
izi\prestashop\Form\Type\Order\AvailablePaymentOptionsChoiceType:
|
||||
class: izi\prestashop\Form\Type\Order\AvailablePaymentOptionsChoiceType
|
||||
tags:
|
||||
- { name: form.type }
|
||||
arguments:
|
||||
- '@izi\prestashop\Form\ChoiceList\AvailablePaymentOptionChoiceLoader'
|
||||
- '@izi\prestashop\Translation\PaymentTypeTranslator'
|
||||
|
||||
izi\prestashop\Form\Type\Order\MessageOptionsType:
|
||||
class: izi\prestashop\Form\Type\Order\MessageOptionsType
|
||||
tags:
|
||||
- { name: form.type }
|
||||
arguments:
|
||||
- '@izi\prestashop\Translation\LegacyTranslator'
|
||||
- '@izi\prestashop\Order\Message\ParameterDescriptorInterface'
|
||||
|
||||
izi\prestashop\Form\Type\ShippingConfigurationType:
|
||||
class: izi\prestashop\Form\Type\ShippingConfigurationType
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: form.type }
|
||||
|
||||
izi\prestashop\Form\Type\AdvancedConfigurationType:
|
||||
class: izi\prestashop\Form\Type\AdvancedConfigurationType
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: form.type }
|
||||
|
||||
izi\prestashop\Form\Type\Shipping\CarrierChoiceType:
|
||||
class: izi\prestashop\Form\Type\Shipping\CarrierChoiceType
|
||||
tags:
|
||||
- { name: form.type }
|
||||
arguments:
|
||||
- '@izi\prestashop\Form\ChoiceList\CarrierChoiceLoader'
|
||||
|
||||
izi\prestashop\Form\Type\Shipping\CarrierMappingsType:
|
||||
class: izi\prestashop\Form\Type\Shipping\CarrierMappingsType
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: form.type }
|
||||
|
||||
izi\prestashop\Form\Type\Shipping\CarrierMappingType:
|
||||
class: izi\prestashop\Form\Type\Shipping\CarrierMappingType
|
||||
tags:
|
||||
- { name: form.type }
|
||||
|
||||
izi\prestashop\Form\Type\Shipping\OptionalServicesType:
|
||||
class: izi\prestashop\Form\Type\Shipping\OptionalServicesType
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: form.type }
|
||||
|
||||
izi\prestashop\Form\Type\Shipping\ServiceOptionsType:
|
||||
class: izi\prestashop\Form\Type\Shipping\ServiceOptionsType
|
||||
tags:
|
||||
- { name: form.type }
|
||||
arguments:
|
||||
- '@izi\prestashop\Translation\LegacyTranslator'
|
||||
- '@inpost.izi.context'
|
||||
|
||||
izi\prestashop\Form\Type\Shipping\ShippingOptionsType:
|
||||
class: izi\prestashop\Form\Type\Shipping\ShippingOptionsType
|
||||
tags:
|
||||
- { name: form.type }
|
||||
|
||||
izi\prestashop\Form\Type\Shipping\TimeOfWeekType:
|
||||
class: izi\prestashop\Form\Type\Shipping\TimeOfWeekType
|
||||
tags:
|
||||
- { name: form.type }
|
||||
|
||||
izi\prestashop\Form\Type\Shipping\TimeOfWeekRangeType:
|
||||
class: izi\prestashop\Form\Type\Shipping\TimeOfWeekRangeType
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: form.type }
|
||||
|
||||
izi\prestashop\Form\Type\Shipping\WeekDayChoiceType:
|
||||
class: izi\prestashop\Form\Type\Shipping\WeekDayChoiceType
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: form.type }
|
||||
|
||||
izi\prestashop\Form\Type\OrderStatusDescriptionMapType:
|
||||
class: izi\prestashop\Form\Type\OrderStatusDescriptionMapType
|
||||
tags:
|
||||
- { name: form.type }
|
||||
arguments:
|
||||
- '@inpost.izi.context'
|
||||
- '@izi\prestashop\Form\ChoiceList\OrderStateChoiceLoader'
|
||||
|
||||
izi\prestashop\Form\Type\Image\ImageTypeChoiceType:
|
||||
class: izi\prestashop\Form\Type\Image\ImageTypeChoiceType
|
||||
tags:
|
||||
- { name: form.type }
|
||||
arguments:
|
||||
- '@izi\prestashop\Form\ChoiceList\ProductImageTypeChoiceLoader'
|
||||
|
||||
izi\prestashop\Form\Type\ProductConfigurationType:
|
||||
class: izi\prestashop\Form\Type\ProductConfigurationType
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: form.type }
|
||||
|
||||
izi\prestashop\Form\Type\ObjectModelAutocompleteType:
|
||||
class: izi\prestashop\Form\Type\ObjectModelAutocompleteType
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: form.type }
|
||||
|
||||
izi\prestashop\Form\Type\Product\ProductRestrictionsType:
|
||||
class: izi\prestashop\Form\Type\Product\ProductRestrictionsType
|
||||
tags:
|
||||
- { name: form.type }
|
||||
arguments:
|
||||
- '@izi\prestashop\Translation\LegacyTranslator'
|
||||
- '@inpost.izi.context'
|
||||
|
||||
izi\prestashop\Form\Type\Widget\ProductPageDisplayConfigurationType:
|
||||
class: izi\prestashop\Form\Type\Widget\ProductPageDisplayConfigurationType
|
||||
tags:
|
||||
- { name: form.type }
|
||||
arguments:
|
||||
- '@izi\prestashop\Translation\LegacyTranslator'
|
||||
|
||||
izi\prestashop\Form\ChoiceList\OrderStateChoiceLoader:
|
||||
class: izi\prestashop\Form\ChoiceList\OrderStateChoiceLoader
|
||||
public: false
|
||||
arguments:
|
||||
- '@inpost.izi.object_model.order_state_repository'
|
||||
|
||||
izi\prestashop\Form\ChoiceList\AvailablePaymentOptionChoiceLoader:
|
||||
class: izi\prestashop\Form\ChoiceList\AvailablePaymentOptionChoiceLoader
|
||||
public: false
|
||||
autowire: true
|
||||
|
||||
izi\prestashop\Form\ChoiceList\CarrierChoiceLoader:
|
||||
class: izi\prestashop\Form\ChoiceList\CarrierChoiceLoader
|
||||
public: false
|
||||
arguments:
|
||||
- '@izi\prestashop\ObjectModel\Repository\CarrierRepository'
|
||||
|
||||
izi\prestashop\Form\ChoiceList\ProductImageTypeChoiceLoader:
|
||||
class: izi\prestashop\Form\ChoiceList\ProductImageTypeChoiceLoader
|
||||
public: false
|
||||
arguments:
|
||||
- '@izi\prestashop\ObjectModel\Repository\ImageTypeRepository'
|
||||
|
||||
izi\prestashop\Handler\Config\UpdateGeneralConfigurationHandlerInterface: '@izi\prestashop\Handler\Config\UpdateGeneralConfigurationHandler'
|
||||
izi\prestashop\Handler\Config\UpdateGeneralConfigurationHandler:
|
||||
class: izi\prestashop\Handler\Config\UpdateGeneralConfigurationHandler
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.command_handler }
|
||||
arguments:
|
||||
- '@izi\prestashop\Configuration\ApiConfigurationInterface'
|
||||
- '@izi\prestashop\Configuration\OrdersConfigurationInterface'
|
||||
- '@izi\prestashop\Configuration\GeneralConfigurationInterface'
|
||||
- '@izi\prestashop\Configuration\ProductConfigurationInterface'
|
||||
- '@izi\prestashop\CacheClearer\CacheClearerInterface'
|
||||
- '@inpost.izi.module'
|
||||
|
||||
izi\prestashop\BasketApp\BasketAppClientFactory:
|
||||
class: izi\prestashop\BasketApp\BasketAppClientFactory
|
||||
public: false
|
||||
arguments:
|
||||
- '@inpost.izi.psr17_factory'
|
||||
- '@inpost.izi.psr17_factory'
|
||||
- '@inpost.izi.serializer'
|
||||
- '@izi\prestashop\Http\Client\Factory\GuzzleClientFactory'
|
||||
- '@izi\prestashop\BasketApp\AuthorizationProviderFactory'
|
||||
|
||||
izi\prestashop\Form\BasketAppClientProvider:
|
||||
class: izi\prestashop\Form\BasketAppClientProvider
|
||||
tags:
|
||||
- { name: kernel.event_subscriber }
|
||||
arguments:
|
||||
- '@izi\prestashop\Configuration\ApiConfigurationInterface'
|
||||
- '@izi\prestashop\BasketApp\BasketAppClientFactory'
|
||||
- '@izi\prestashop\BasketApp\BasketAppClient'
|
||||
|
||||
izi\prestashop\Validator\InPostApiCredentialsValidator:
|
||||
class: izi\prestashop\Validator\InPostApiCredentialsValidator
|
||||
tags:
|
||||
- { name: validator.constraint_validator }
|
||||
arguments:
|
||||
- '@izi\prestashop\Translation\LegacyTranslator'
|
||||
- '@izi\prestashop\BasketApp\AuthorizationProviderFactory'
|
||||
|
||||
izi\prestashop\Validator\NotBlankInDefaultLanguageValidator:
|
||||
class: izi\prestashop\Validator\NotBlankInDefaultLanguageValidator
|
||||
tags:
|
||||
- { name: validator.constraint_validator }
|
||||
arguments:
|
||||
- '@izi\prestashop\Configuration\Adapter\Configuration'
|
||||
|
||||
izi\prestashop\Validator\ProcessableMessageFormatValidator:
|
||||
class: izi\prestashop\Validator\ProcessableMessageFormatValidator
|
||||
tags:
|
||||
- { name: validator.constraint_validator }
|
||||
arguments:
|
||||
- '@izi\prestashop\Order\Message\MessageFormatterInterface'
|
||||
- '@izi\prestashop\Translation\LegacyTranslator'
|
||||
|
||||
izi\prestashop\Validator\Consent\DescriptionUsesIdPlaceholdersValidator:
|
||||
class: izi\prestashop\Validator\Consent\DescriptionUsesIdPlaceholdersValidator
|
||||
tags:
|
||||
- { name: validator.constraint_validator }
|
||||
arguments:
|
||||
- '@izi\prestashop\Translation\LegacyTranslator'
|
||||
|
||||
izi\prestashop\Validator\Consent\UniqueIdentifiersValidator:
|
||||
class: izi\prestashop\Validator\Consent\UniqueIdentifiersValidator
|
||||
tags:
|
||||
- { name: validator.constraint_validator }
|
||||
arguments:
|
||||
- '@izi\prestashop\Translation\LegacyTranslator'
|
||||
|
||||
izi\prestashop\Command\Config\UpdateGeneralConfigurationCommandFactory:
|
||||
class: izi\prestashop\Command\Config\UpdateGeneralConfigurationCommandFactory
|
||||
arguments:
|
||||
- '@izi\prestashop\Configuration\ApiConfigurationInterface'
|
||||
- '@izi\prestashop\Configuration\OrdersConfigurationInterface'
|
||||
- '@izi\prestashop\Configuration\GeneralConfigurationInterface'
|
||||
- '@izi\prestashop\Configuration\ProductConfigurationInterface'
|
||||
|
||||
izi\prestashop\Form\Type\ConsentsConfigurationType:
|
||||
class: izi\prestashop\Form\Type\ConsentsConfigurationType
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: form.type }
|
||||
|
||||
izi\prestashop\Form\Type\Consent\ConsentType:
|
||||
class: izi\prestashop\Form\Type\Consent\ConsentType
|
||||
tags:
|
||||
- { name: form.type }
|
||||
arguments:
|
||||
- '@izi\prestashop\Translation\LegacyTranslator'
|
||||
|
||||
izi\prestashop\Form\Type\Consent\ConsentLinkType:
|
||||
class: izi\prestashop\Form\Type\Consent\ConsentLinkType
|
||||
tags:
|
||||
- { name: form.type }
|
||||
arguments:
|
||||
- '@izi\prestashop\Translation\LegacyTranslator'
|
||||
- '@inpost.izi.context'
|
||||
- '@izi\prestashop\ObjectModel\Repository\CmsPageRepository'
|
||||
|
||||
izi\prestashop\Form\Type\Consent\ConsentRequirementChoiceType:
|
||||
class: izi\prestashop\Form\Type\Consent\ConsentRequirementChoiceType
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: form.type }
|
||||
|
||||
izi\prestashop\Handler\Config\UpdateConsentsConfigurationHandlerInterface: '@izi\prestashop\Handler\Config\UpdateConsentsConfigurationHandler'
|
||||
izi\prestashop\Handler\Config\UpdateConsentsConfigurationHandler:
|
||||
class: izi\prestashop\Handler\Config\UpdateConsentsConfigurationHandler
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.command_handler }
|
||||
arguments:
|
||||
- '@izi\prestashop\Configuration\ConsentsConfigurationInterface'
|
||||
- '@inpost.izi.clock'
|
||||
|
||||
izi\prestashop\Form\Type\GuiConfigurationType:
|
||||
class: izi\prestashop\Form\Type\GuiConfigurationType
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: form.type }
|
||||
|
||||
izi\prestashop\Form\Type\Widget\WidgetDisplayConfigurationType:
|
||||
class: izi\prestashop\Form\Type\Widget\WidgetDisplayConfigurationType
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: form.type }
|
||||
|
||||
izi\prestashop\Form\Type\Widget\HtmlStylesType:
|
||||
class: izi\prestashop\Form\Type\Widget\HtmlStylesType
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: form.type }
|
||||
|
||||
izi\prestashop\Form\Type\Widget\WidgetConfigurationType:
|
||||
class: izi\prestashop\Form\Type\Widget\WidgetConfigurationType
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: form.type }
|
||||
|
||||
izi\prestashop\Form\Type\Widget\WidgetVariantChoiceType:
|
||||
class: izi\prestashop\Form\Type\Widget\WidgetVariantChoiceType
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: form.type }
|
||||
|
||||
izi\prestashop\Form\Type\Widget\WidgetFrameStyleChoiceType:
|
||||
class: izi\prestashop\Form\Type\Widget\WidgetFrameStyleChoiceType
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: form.type }
|
||||
|
||||
izi\prestashop\Form\Type\Widget\WidgetSizeChoiceType:
|
||||
class: izi\prestashop\Form\Type\Widget\WidgetSizeChoiceType
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: form.type }
|
||||
|
||||
izi\prestashop\HotProduct\Form\UpdateHotProductType:
|
||||
class: izi\prestashop\HotProduct\Form\UpdateHotProductType
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: form.type }
|
||||
|
||||
izi\prestashop\HotProduct\Form\CreateHotProductType:
|
||||
class: izi\prestashop\HotProduct\Form\CreateHotProductType
|
||||
tags:
|
||||
- { name: form.type }
|
||||
arguments:
|
||||
- '@inpost.izi.context'
|
||||
- '@izi\prestashop\Translation\LegacyTranslator'
|
||||
- '@router'
|
||||
|
||||
izi\prestashop\Form\Type\Product\CombinationByAttributesChoiceType:
|
||||
class: izi\prestashop\Form\Type\Product\CombinationByAttributesChoiceType
|
||||
tags:
|
||||
- { name: form.type }
|
||||
arguments:
|
||||
- '@izi\prestashop\ObjectModel\ObjectManagerInterface'
|
||||
- '@inpost.izi.context'
|
||||
- '@izi\prestashop\Translation\LegacyTranslator'
|
||||
|
||||
izi\prestashop\Handler\Config\UpdateGuiConfigurationHandlerInterface: '@izi\prestashop\Handler\Config\UpdateGuiConfigurationHandler'
|
||||
izi\prestashop\Handler\Config\UpdateGuiConfigurationHandler:
|
||||
class: izi\prestashop\Handler\Config\UpdateGuiConfigurationHandler
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.command_handler }
|
||||
arguments:
|
||||
- '@izi\prestashop\Configuration\GuiConfigurationInterface'
|
||||
|
||||
izi\prestashop\Handler\Config\UpdateShippingConfigurationHandlerInterface: '@izi\prestashop\Handler\Config\UpdateShippingConfigurationHandler'
|
||||
izi\prestashop\Handler\Config\UpdateShippingConfigurationHandler:
|
||||
class: izi\prestashop\Handler\Config\UpdateShippingConfigurationHandler
|
||||
public: false
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: inpost.izi.command_handler }
|
||||
|
||||
izi\prestashop\Handler\Config\UpdateAdvancedConfigurationHandlerInterface: '@izi\prestashop\Handler\Config\UpdateAdvancedConfigurationHandler'
|
||||
izi\prestashop\Handler\Config\UpdateAdvancedConfigurationHandler:
|
||||
class: izi\prestashop\Handler\Config\UpdateAdvancedConfigurationHandler
|
||||
public: false
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: inpost.izi.command_handler }
|
||||
|
||||
izi\prestashop\Handler\Config\CheckStatusHandlerInterface: '@izi\prestashop\Handler\Config\CheckStatusHandler'
|
||||
izi\prestashop\Handler\Config\CheckStatusHandler:
|
||||
class: izi\prestashop\Handler\Config\CheckStatusHandler
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.command_handler }
|
||||
arguments:
|
||||
- !tagged inpost.izi.status_checker
|
||||
|
||||
izi\prestashop\Handler\Config\DownloadModuleDataHandlerInterface: '@izi\prestashop\Handler\Config\DownloadModuleDataHandler'
|
||||
izi\prestashop\Handler\Config\DownloadModuleDataHandler:
|
||||
class: izi\prestashop\Handler\Config\DownloadModuleDataHandler
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.command_handler }
|
||||
arguments:
|
||||
- '@inpost.izi.module'
|
||||
- '@inpost.izi.context'
|
||||
- '@izi\prestashop\ObjectModel\ObjectManagerInterface'
|
||||
- '%inpost.izi.logs_dir%'
|
||||
|
||||
izi\prestashop\Twig\Extension\LegacyTranslationExtension:
|
||||
class: izi\prestashop\Twig\Extension\LegacyTranslationExtension
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.twig_extension }
|
||||
arguments:
|
||||
- '@izi\prestashop\Translation\LegacyTranslator'
|
||||
|
||||
izi\prestashop\Handler\Config\Status\ConfigurationStatusChecker:
|
||||
class: izi\prestashop\Handler\Config\Status\ConfigurationStatusChecker
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.status_checker }
|
||||
arguments:
|
||||
- '@izi\prestashop\Translation\LegacyTranslator'
|
||||
- '@izi\prestashop\Configuration\OrdersConfigurationInterface'
|
||||
- '@izi\prestashop\Configuration\ApiConfigurationInterface'
|
||||
- '@validator'
|
||||
|
||||
izi\prestashop\Handler\Config\Status\DeliveryOptionsStatusChecker:
|
||||
class: izi\prestashop\Handler\Config\Status\DeliveryOptionsStatusChecker
|
||||
public: false
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: inpost.izi.status_checker }
|
||||
arguments:
|
||||
- '@izi\prestashop\Translation\LegacyTranslator'
|
||||
- '@izi\prestashop\ObjectModel\Repository\CarrierRepository'
|
||||
|
||||
izi\prestashop\Handler\Config\Status\CacheStatusChecker:
|
||||
class: izi\prestashop\Handler\Config\Status\CacheStatusChecker
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.status_checker }
|
||||
arguments:
|
||||
- '@inpost.izi.module'
|
||||
- '@service_container'
|
||||
|
||||
izi\prestashop\Translation\LegacyTranslator:
|
||||
class: izi\prestashop\Translation\LegacyTranslator
|
||||
public: false
|
||||
arguments:
|
||||
- inpostizi
|
||||
|
||||
izi\prestashop\Translation\ServiceNameTranslator:
|
||||
class: izi\prestashop\Translation\ServiceNameTranslator
|
||||
public: false
|
||||
autowire: true
|
||||
|
||||
izi\prestashop\Translation\PaymentTypeTranslator:
|
||||
class: izi\prestashop\Translation\PaymentTypeTranslator
|
||||
public: false
|
||||
autowire: true
|
||||
|
||||
izi\prestashop\Configuration\Initializer\AssetPackageInitializer:
|
||||
class: izi\prestashop\Configuration\Initializer\AssetPackageInitializer
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.config_initializer }
|
||||
arguments:
|
||||
- '@assets.packages'
|
||||
- '@izi\prestashop\View\Asset\AssetManagerInterface'
|
||||
- InPostIzi
|
||||
|
||||
izi\prestashop\Configuration\Initializer\AnnotationsConfigInitializer:
|
||||
class: izi\prestashop\Configuration\Initializer\AnnotationsConfigInitializer
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.config_initializer }
|
||||
|
||||
izi\prestashop\Configuration\Initializer\TwigConfigInitializer:
|
||||
class: izi\prestashop\Configuration\Initializer\TwigConfigInitializer
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.config_initializer }
|
||||
arguments:
|
||||
- '@twig'
|
||||
- !tagged inpost.izi.twig_extension
|
||||
|
||||
izi\prestashop\Order\Message\ParameterDescriptorInterface: '@izi\prestashop\Order\Message\ParametersExtractor'
|
||||
|
||||
izi\prestashop\Configuration\GuiConfiguration:
|
||||
class: izi\prestashop\Configuration\GuiConfiguration
|
||||
autowire: true
|
||||
public: false
|
||||
tags:
|
||||
- { name: container.service_subscriber, key: context, id: inpost.izi.shop_context }
|
||||
arguments:
|
||||
- '@izi\prestashop\Configuration\Adapter\Configuration'
|
||||
- '@inpost.izi.serializer'
|
||||
|
||||
inpost.izi.security.authorization_checker: '@security.authorization_checker'
|
||||
inpost.izi.validator: '@validator'
|
||||
|
||||
izi\prestashop\CacheClearer\CacheClearerInterface: '@izi\prestashop\CacheClearer\ChainCacheClearer'
|
||||
izi\prestashop\CacheClearer\ChainCacheClearer:
|
||||
class: izi\prestashop\CacheClearer\ChainCacheClearer
|
||||
public: false
|
||||
arguments:
|
||||
- !tagged inpost.izi.cache_clearer
|
||||
|
||||
inpost.izi.config_cache_clearer:
|
||||
class: izi\prestashop\CacheClearer\Psr16CacheClearer
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.cache_clearer }
|
||||
arguments:
|
||||
- '@izi\prestashop\Cache\ConfigurationCache'
|
||||
|
||||
izi\prestashop\CacheClearer\BindingKeysCacheClearer:
|
||||
class: izi\prestashop\CacheClearer\BindingKeysCacheClearer
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.cache_clearer }
|
||||
arguments:
|
||||
- '@izi\prestashop\Repository\BasketSessionRepository'
|
||||
|
||||
izi\prestashop\HotProduct\MessageHandler\CreateHotProductHandlerInterface: '@izi\prestashop\HotProduct\MessageHandler\CreateHotProductHandler'
|
||||
izi\prestashop\HotProduct\MessageHandler\CreateHotProductHandler:
|
||||
class: izi\prestashop\HotProduct\MessageHandler\CreateHotProductHandler
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.command_handler }
|
||||
arguments:
|
||||
- '@izi\prestashop\HotProduct\HotProductRepositoryInterface'
|
||||
- '@izi\prestashop\HotProduct\HotProductValidator'
|
||||
- '@izi\prestashop\HotProduct\HotProductDataMapperInterface'
|
||||
- '@izi\prestashop\BasketApp\Product\ProductsApiClientInterface'
|
||||
|
||||
izi\prestashop\HotProduct\MessageHandler\ImportHotProductHandlerInterface: '@izi\prestashop\HotProduct\MessageHandler\ImportHotProductHandler'
|
||||
izi\prestashop\HotProduct\MessageHandler\ImportHotProductHandler:
|
||||
class: izi\prestashop\HotProduct\MessageHandler\ImportHotProductHandler
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.command_handler }
|
||||
arguments:
|
||||
- '@izi\prestashop\HotProduct\HotProductRepositoryInterface'
|
||||
- '@izi\prestashop\ObjectModel\Repository\ProductRepository'
|
||||
- '@izi\prestashop\BasketApp\Product\ProductsApiClientInterface'
|
||||
- '@izi\prestashop\HotProduct\HotProductDataMapperInterface'
|
||||
|
||||
izi\prestashop\HotProduct\MessageHandler\DeleteHotProductHandlerInterface: '@izi\prestashop\HotProduct\MessageHandler\DeleteHotProductHandler'
|
||||
izi\prestashop\HotProduct\MessageHandler\DeleteHotProductHandler:
|
||||
class: izi\prestashop\HotProduct\MessageHandler\DeleteHotProductHandler
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.command_handler }
|
||||
arguments:
|
||||
- '@izi\prestashop\HotProduct\HotProductRepositoryInterface'
|
||||
- '@izi\prestashop\BasketApp\Product\ProductsApiClientInterface'
|
||||
|
||||
izi\prestashop\HotProduct\View\HotProductViewDataFactory:
|
||||
class: izi\prestashop\HotProduct\View\HotProductViewDataFactory
|
||||
arguments:
|
||||
- '@inpost.izi.context'
|
||||
- '@izi\prestashop\ObjectModel\Repository\ProductRepository'
|
||||
- '@inpost.izi.object_model.shop_repository'
|
||||
- '@izi\prestashop\BasketApp\Product\ProductsApiClientInterface'
|
||||
|
||||
izi\prestashop\EventListener\CreateShipmentListener:
|
||||
class: izi\prestashop\EventListener\CreateShipmentListener
|
||||
tags:
|
||||
- { name: kernel.event_subscriber }
|
||||
arguments:
|
||||
- '@izi\prestashop\Repository\OrderDataRepositoryInterface'
|
||||
- '@izi\prestashop\Translation\LegacyTranslator'
|
||||
30
modules/inpostizi/config/services/admin/form.php
Normal file
30
modules/inpostizi/config/services/admin/form.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use izi\prestashop\Form\TypeExtension\DatePickerCompatibilityTypeExtension;
|
||||
use izi\prestashop\Form\TypeExtension\DateTimeImmutableTimeTypeExtension;
|
||||
use izi\prestashop\Form\TypeExtension\HelpTextExtension;
|
||||
use izi\prestashop\Form\TypeExtension\UnitTypeExtension;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
|
||||
if (!defined('_PS_VERSION_') || Tools::version_compare(_PS_VERSION_, '8.0.0')) {
|
||||
return;
|
||||
}
|
||||
|
||||
assert(isset($container) && $container instanceof ContainerBuilder);
|
||||
|
||||
$classes = [
|
||||
DateTimeImmutableTimeTypeExtension::class,
|
||||
HelpTextExtension::class,
|
||||
UnitTypeExtension::class,
|
||||
];
|
||||
|
||||
$container->removeDefinition(DatePickerCompatibilityTypeExtension::class);
|
||||
|
||||
foreach ($classes as $class) {
|
||||
$container
|
||||
->getDefinition($class)
|
||||
->setTags([])
|
||||
->setDeprecated();
|
||||
}
|
||||
20
modules/inpostizi/config/services/admin/form.yml
Normal file
20
modules/inpostizi/config/services/admin/form.yml
Normal file
@@ -0,0 +1,20 @@
|
||||
services:
|
||||
izi\prestashop\Form\TypeExtension\DatePickerCompatibilityTypeExtension:
|
||||
class: izi\prestashop\Form\TypeExtension\DatePickerCompatibilityTypeExtension
|
||||
tags:
|
||||
- { name: form.type_extension, extended_type: PrestaShopBundle\Form\Admin\Type\DatePickerType }
|
||||
|
||||
izi\prestashop\Form\TypeExtension\DateTimeImmutableTimeTypeExtension:
|
||||
class: izi\prestashop\Form\TypeExtension\DateTimeImmutableTimeTypeExtension
|
||||
tags:
|
||||
- { name: form.type_extension, extended_type: Symfony\Component\Form\Extension\Core\Type\TimeType }
|
||||
|
||||
izi\prestashop\Form\TypeExtension\HelpTextExtension:
|
||||
class: izi\prestashop\Form\TypeExtension\HelpTextExtension
|
||||
tags:
|
||||
- { name: form.type_extension, extended_type: Symfony\Component\Form\Extension\Core\Type\FormType }
|
||||
|
||||
izi\prestashop\Form\TypeExtension\UnitTypeExtension:
|
||||
class: izi\prestashop\Form\TypeExtension\UnitTypeExtension
|
||||
tags:
|
||||
- { name: form.type_extension, extended_type: Symfony\Component\Form\Extension\Core\Type\IntegerType }
|
||||
1324
modules/inpostizi/config/services/common.yml
Normal file
1324
modules/inpostizi/config/services/common.yml
Normal file
File diff suppressed because it is too large
Load Diff
47
modules/inpostizi/config/services/common_admin.yml
Normal file
47
modules/inpostizi/config/services/common_admin.yml
Normal file
@@ -0,0 +1,47 @@
|
||||
# common BO configuration
|
||||
imports:
|
||||
- { resource: admin/form.yml }
|
||||
- { resource: admin/form.php, ignore_errors: true }
|
||||
|
||||
services:
|
||||
izi\prestashop\View\Asset\AssetManagerInterface: '@izi\prestashop\View\Asset\AdminAssetManager'
|
||||
izi\prestashop\View\Asset\AdminAssetManager:
|
||||
class: izi\prestashop\View\Asset\AdminAssetManager
|
||||
public: false
|
||||
arguments:
|
||||
- '@inpost.izi.module'
|
||||
- '@inpost.izi.context'
|
||||
|
||||
izi\prestashop\View\Asset\Provider\Admin\CartRulesAssetsProvider:
|
||||
class: izi\prestashop\View\Asset\Provider\Admin\CartRulesAssetsProvider
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.admin_assets_provider }
|
||||
arguments:
|
||||
- '@inpost.izi.context'
|
||||
- '@inpost.izi.request_stack'
|
||||
|
||||
izi\prestashop\Handler\Config\UpdateCartRuleOptionsHandlerInterface: '@izi\prestashop\Handler\Config\UpdateCartRuleOptionsHandler'
|
||||
izi\prestashop\Handler\Config\UpdateCartRuleOptionsHandler:
|
||||
class: izi\prestashop\Handler\Config\UpdateCartRuleOptionsHandler
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.command_handler }
|
||||
arguments:
|
||||
- '@izi\prestashop\PromoCode\CartRuleOptionsRepositoryInterface'
|
||||
|
||||
izi\prestashop\Form\Type\CartRuleOptionsType:
|
||||
class: izi\prestashop\Form\Type\CartRuleOptionsType
|
||||
tags:
|
||||
- { name: form.type }
|
||||
arguments:
|
||||
- '@izi\prestashop\Translation\LegacyTranslator'
|
||||
- '@inpost.izi.context'
|
||||
|
||||
izi\prestashop\Form\Type\ObjectModelType:
|
||||
class: izi\prestashop\Form\Type\ObjectModelType
|
||||
tags:
|
||||
- { name: form.type }
|
||||
arguments:
|
||||
- '@izi\prestashop\ObjectModel\ObjectManagerInterface'
|
||||
- '@inpost.izi.context'
|
||||
490
modules/inpostizi/config/services/common_front.yml
Normal file
490
modules/inpostizi/config/services/common_front.yml
Normal file
@@ -0,0 +1,490 @@
|
||||
# common FO configuration
|
||||
services:
|
||||
izi\prestashop\View\Asset\FrontAssetManager:
|
||||
class: izi\prestashop\View\Asset\FrontAssetManager
|
||||
public: false
|
||||
arguments:
|
||||
- '@inpost.izi.module'
|
||||
- '@inpost.izi.context'
|
||||
|
||||
izi\prestashop\Hook\Front\ActionFrontControllerSetMedia:
|
||||
class: izi\prestashop\Hook\Front\ActionFrontControllerSetMedia
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.hook }
|
||||
arguments:
|
||||
- '@izi\prestashop\View\Asset\FrontAssetManager'
|
||||
- '@inpost.izi.security.authorization_checker'
|
||||
- !tagged inpost.izi.front_assets_provider
|
||||
- '@izi\prestashop\Configuration\ApiConfigurationInterface'
|
||||
|
||||
izi\prestashop\Hook\Front\DisplayHeader:
|
||||
class: izi\prestashop\Hook\Front\DisplayHeader
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.hook }
|
||||
arguments:
|
||||
- '@inpost.izi.context'
|
||||
- '@izi\prestashop\Configuration\GeneralConfigurationInterface'
|
||||
- '@izi\prestashop\Configuration\ApiConfigurationInterface'
|
||||
- '@inpost.izi.security.authorization_checker'
|
||||
- '@izi\prestashop\Analytics\Cookie\Executor\CookiePersisterExecutor'
|
||||
- '@izi\prestashop\Repository\BasketSessionRepository'
|
||||
- '@izi\prestashop\Event\EventDispatcherInterface'
|
||||
|
||||
izi\prestashop\Hook\Front\ActionGetPaymentOptions:
|
||||
class: izi\prestashop\Hook\Front\ActionGetPaymentOptions
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.hook }
|
||||
arguments:
|
||||
- '@inpost.izi.module'
|
||||
- '@izi\prestashop\Payment\PaymentCurrencyChecker'
|
||||
- '@izi\prestashop\Configuration\GuiConfiguration'
|
||||
- '@izi\prestashop\View\Templating\RendererInterface'
|
||||
|
||||
izi\prestashop\Hook\Front\DisplayIziThankYou:
|
||||
class: izi\prestashop\Hook\Front\DisplayIziThankYou
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.hook }
|
||||
arguments:
|
||||
- '@inpost.izi.module'
|
||||
- '@izi\prestashop\Configuration\GeneralConfiguration'
|
||||
|
||||
izi\prestashop\Hook\Front\DisplayOrderConfirmation:
|
||||
class: izi\prestashop\Hook\Front\DisplayOrderConfirmation
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.hook }
|
||||
arguments:
|
||||
- '@izi\prestashop\Repository\BasketSessionRepository'
|
||||
- '@inpost.izi.context'
|
||||
- '@inpost.izi.module'
|
||||
- '@izi\prestashop\Configuration\GeneralConfiguration'
|
||||
|
||||
izi\prestashop\Hook\Front\DisplayPaymentReturn:
|
||||
class: izi\prestashop\Hook\Front\DisplayPaymentReturn
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.hook }
|
||||
arguments:
|
||||
- '@inpost.izi.module'
|
||||
- '@izi\prestashop\Configuration\GeneralConfiguration'
|
||||
|
||||
izi\prestashop\Hook\Front\DisplayProductActions:
|
||||
class: izi\prestashop\Hook\Front\DisplayProductActions
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.hook }
|
||||
arguments:
|
||||
- '@izi\prestashop\Configuration\GuiConfiguration'
|
||||
- '@izi\prestashop\Configuration\GeneralConfiguration'
|
||||
- '@inpost.izi.module'
|
||||
- '@izi\prestashop\View\Templating\RendererInterface'
|
||||
- '@inpost.izi.context'
|
||||
- '@izi\prestashop\Repository\BasketSessionRepository'
|
||||
|
||||
izi\prestashop\Hook\Front\DisplayProductAdditionalInfo:
|
||||
class: izi\prestashop\Hook\Front\DisplayProductAdditionalInfo
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.hook }
|
||||
arguments:
|
||||
- '@izi\prestashop\Configuration\GuiConfiguration'
|
||||
- '@izi\prestashop\Configuration\GeneralConfiguration'
|
||||
- '@inpost.izi.module'
|
||||
- '@izi\prestashop\View\Templating\RendererInterface'
|
||||
- '@inpost.izi.context'
|
||||
- '@izi\prestashop\Repository\BasketSessionRepository'
|
||||
|
||||
izi\prestashop\Hook\Front\DisplayShoppingCart:
|
||||
class: izi\prestashop\Hook\Front\DisplayShoppingCart
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.hook }
|
||||
arguments:
|
||||
- '@izi\prestashop\Configuration\GuiConfiguration'
|
||||
- '@inpost.izi.module'
|
||||
- '@izi\prestashop\View\Templating\RendererInterface'
|
||||
|
||||
izi\prestashop\Hook\Front\DisplayShoppingCartFooter:
|
||||
class: izi\prestashop\Hook\Front\DisplayShoppingCartFooter
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.hook }
|
||||
arguments:
|
||||
- '@izi\prestashop\Configuration\GuiConfiguration'
|
||||
- '@inpost.izi.module'
|
||||
- '@izi\prestashop\View\Templating\RendererInterface'
|
||||
|
||||
izi\prestashop\Hook\Front\DisplayExpressCheckout:
|
||||
class: izi\prestashop\Hook\Front\DisplayExpressCheckout
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.hook }
|
||||
arguments:
|
||||
- '@izi\prestashop\Configuration\GuiConfiguration'
|
||||
- '@inpost.izi.module'
|
||||
- '@izi\prestashop\View\Templating\RendererInterface'
|
||||
|
||||
izi\prestashop\Hook\Front\DisplayCheckoutSummaryTop:
|
||||
class: izi\prestashop\Hook\Front\DisplayCheckoutSummaryTop
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.hook }
|
||||
arguments:
|
||||
- '@izi\prestashop\Configuration\GuiConfiguration'
|
||||
- '@izi\prestashop\Configuration\GeneralConfiguration'
|
||||
- '@inpost.izi.module'
|
||||
- '@izi\prestashop\View\Templating\RendererInterface'
|
||||
|
||||
izi\prestashop\Hook\Front\DisplayCustomerAccountFormTop:
|
||||
class: izi\prestashop\Hook\Front\DisplayCustomerAccountFormTop
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.hook }
|
||||
arguments:
|
||||
- '@izi\prestashop\Configuration\GuiConfiguration'
|
||||
- '@inpost.izi.module'
|
||||
- '@izi\prestashop\View\Templating\RendererInterface'
|
||||
|
||||
izi\prestashop\Hook\Front\DisplayCustomerLoginFormAfter:
|
||||
class: izi\prestashop\Hook\Front\DisplayCustomerLoginFormAfter
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.hook }
|
||||
arguments:
|
||||
- '@izi\prestashop\Configuration\GuiConfiguration'
|
||||
- '@inpost.izi.module'
|
||||
- '@izi\prestashop\View\Templating\RendererInterface'
|
||||
|
||||
izi\prestashop\Hook\Front\DisplayIziCartPreviewButton:
|
||||
class: izi\prestashop\Hook\Front\DisplayIziCartPreviewButton
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.hook }
|
||||
arguments:
|
||||
- '@izi\prestashop\Configuration\GuiConfiguration'
|
||||
- '@inpost.izi.module'
|
||||
- '@izi\prestashop\View\Templating\RendererInterface'
|
||||
|
||||
izi\prestashop\Hook\Front\DisplayIziCheckoutButton:
|
||||
class: izi\prestashop\Hook\Front\DisplayIziCheckoutButton
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.hook }
|
||||
arguments:
|
||||
- '@izi\prestashop\Configuration\GuiConfiguration'
|
||||
- '@izi\prestashop\Configuration\GeneralConfiguration'
|
||||
- '@inpost.izi.module'
|
||||
- '@izi\prestashop\View\Templating\RendererInterface'
|
||||
|
||||
izi\prestashop\Controller\WidgetController:
|
||||
class: izi\prestashop\Controller\WidgetController
|
||||
public: true
|
||||
arguments:
|
||||
- '@inpost.izi.module'
|
||||
- '@inpost.izi.context'
|
||||
- '@izi\prestashop\CommandBus'
|
||||
- '@inpost.izi.widget_controller_locator'
|
||||
|
||||
izi\prestashop\Controller\Api\BasketController:
|
||||
class: izi\prestashop\Controller\Api\BasketController
|
||||
public: true
|
||||
arguments:
|
||||
- '@inpost.izi.serializer'
|
||||
- '@izi\prestashop\CommandBus'
|
||||
|
||||
izi\prestashop\Controller\Api\OrderController:
|
||||
class: izi\prestashop\Controller\Api\OrderController
|
||||
public: true
|
||||
arguments:
|
||||
- '@inpost.izi.serializer'
|
||||
- '@izi\prestashop\CommandBus'
|
||||
|
||||
izi\prestashop\Controller\Api\ProductController:
|
||||
class: izi\prestashop\Controller\Api\ProductController
|
||||
public: true
|
||||
arguments:
|
||||
- '@inpost.izi.serializer'
|
||||
- '@izi\prestashop\CommandBus'
|
||||
|
||||
izi\prestashop\Handler\GetBasketBindingKeyHandlerInterface: '@izi\prestashop\Handler\GetBasketBindingKeyHandler'
|
||||
izi\prestashop\Handler\GetBasketBindingKeyHandler:
|
||||
class: izi\prestashop\Handler\GetBasketBindingKeyHandler
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.command_handler }
|
||||
arguments:
|
||||
- '@izi\prestashop\Repository\BasketSessionRepository'
|
||||
- '@izi\prestashop\BasketApp\Basket\BasketsApiClientInterface'
|
||||
- '@inpost.izi.context'
|
||||
|
||||
izi\prestashop\Handler\GetOrderConfirmationUrlHandlerInterface: '@izi\prestashop\Handler\GetOrderConfirmationUrlHandler'
|
||||
izi\prestashop\Handler\GetOrderConfirmationUrlHandler:
|
||||
class: izi\prestashop\Handler\GetOrderConfirmationUrlHandler
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.command_handler }
|
||||
arguments:
|
||||
- '@izi\prestashop\Repository\BasketSessionRepository'
|
||||
- '@izi\prestashop\Order\ContextCustomerUpdater'
|
||||
|
||||
izi\prestashop\MerchantApi\Handler\ConfirmBasketBindingHandlerInterface: '@izi\prestashop\MerchantApi\Handler\ConfirmBasketBindingHandler'
|
||||
izi\prestashop\MerchantApi\Handler\ConfirmBasketBindingHandler:
|
||||
class: izi\prestashop\MerchantApi\Handler\ConfirmBasketBindingHandler
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.command_handler }
|
||||
arguments:
|
||||
- '@izi\prestashop\Repository\BasketSessionRepository'
|
||||
- '@izi\prestashop\Builder\Basket\BasketBuilderFactory'
|
||||
|
||||
izi\prestashop\MerchantApi\Handler\DeleteBasketBindingHandlerInterface: '@izi\prestashop\MerchantApi\Handler\DeleteBasketBindingHandler'
|
||||
izi\prestashop\MerchantApi\Handler\DeleteBasketBindingHandler:
|
||||
class: izi\prestashop\MerchantApi\Handler\DeleteBasketBindingHandler
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.command_handler }
|
||||
arguments:
|
||||
- '@izi\prestashop\Repository\BasketSessionRepository'
|
||||
|
||||
izi\prestashop\MerchantApi\Handler\GetBasketHandlerInterface: '@izi\prestashop\MerchantApi\Handler\GetBasketHandler'
|
||||
izi\prestashop\MerchantApi\Handler\GetBasketHandler:
|
||||
class: izi\prestashop\MerchantApi\Handler\GetBasketHandler
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.command_handler }
|
||||
arguments:
|
||||
- '@izi\prestashop\Repository\BasketSessionRepository'
|
||||
- '@izi\prestashop\Builder\Basket\BasketBuilderFactory'
|
||||
|
||||
izi\prestashop\MerchantApi\Handler\UpdateBasketHandlerInterface: '@izi\prestashop\MerchantApi\Handler\UpdateBasketHandler'
|
||||
izi\prestashop\MerchantApi\Handler\UpdateBasketHandler:
|
||||
class: izi\prestashop\MerchantApi\Handler\UpdateBasketHandler
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.command_handler }
|
||||
arguments:
|
||||
- '@izi\prestashop\Repository\BasketSessionRepository'
|
||||
- '@izi\prestashop\MerchantApi\Handler\Basket\BasketEventHandler'
|
||||
- '@izi\prestashop\Builder\Basket\BasketBuilderFactory'
|
||||
|
||||
izi\prestashop\MerchantApi\Handler\GetProductsHandlerInterface: '@izi\prestashop\MerchantApi\Handler\GetProductsHandler'
|
||||
izi\prestashop\MerchantApi\Handler\GetProductsHandler:
|
||||
class: izi\prestashop\MerchantApi\Handler\GetProductsHandler
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.command_handler }
|
||||
arguments:
|
||||
- '@izi\prestashop\HotProduct\HotProductRepositoryInterface'
|
||||
- '@izi\prestashop\HotProduct\HotProductDataMapperInterface'
|
||||
- '@izi\prestashop\BasketApp\Product\ProductsApiClientInterface'
|
||||
- '@izi\prestashop\Cache\ConfigurationCache'
|
||||
- '@izi\prestashop\ObjectModel\Repository\ProductRepository'
|
||||
|
||||
izi\prestashop\MerchantApi\Handler\AddProductToBasketHandlerInterface: '@izi\prestashop\MerchantApi\Handler\AddProductToBasketHandler'
|
||||
izi\prestashop\MerchantApi\Handler\AddProductToBasketHandler:
|
||||
class: izi\prestashop\MerchantApi\Handler\AddProductToBasketHandler
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.command_handler }
|
||||
arguments:
|
||||
- '@izi\prestashop\Repository\BasketSessionRepository'
|
||||
- '@izi\prestashop\ContextManager'
|
||||
- '@izi\prestashop\CommandBusInterface'
|
||||
- '@izi\prestashop\Event\EventDispatcherInterface'
|
||||
- '@izi\prestashop\Builder\Basket\BasketBuilderFactory'
|
||||
|
||||
izi\prestashop\MerchantApi\Handler\CreateOrderHandlerInterface: '@izi\prestashop\MerchantApi\Handler\CreateOrderHandler'
|
||||
izi\prestashop\MerchantApi\Handler\CreateOrderHandler:
|
||||
class: izi\prestashop\MerchantApi\Handler\CreateOrderHandler
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.command_handler }
|
||||
arguments:
|
||||
- '@izi\prestashop\Repository\BasketSessionRepository'
|
||||
- '@izi\prestashop\CommandBusInterface'
|
||||
|
||||
izi\prestashop\MerchantApi\Handler\GetOrderHandlerInterface: '@izi\prestashop\MerchantApi\Handler\GetOrderHandler'
|
||||
izi\prestashop\MerchantApi\Handler\GetOrderHandler:
|
||||
class: izi\prestashop\MerchantApi\Handler\GetOrderHandler
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.command_handler }
|
||||
arguments:
|
||||
- '@inpost.izi.object_model.order_repository'
|
||||
- '@izi\prestashop\Repository\BasketSessionRepository'
|
||||
- '@izi\prestashop\Analytics\BasketAnalyticsRepositoryInterface'
|
||||
|
||||
izi\prestashop\MerchantApi\Handler\UpdateOrderHandlerInterface: '@izi\prestashop\MerchantApi\Handler\UpdateOrderHandler'
|
||||
izi\prestashop\MerchantApi\Handler\UpdateOrderHandler:
|
||||
class: izi\prestashop\MerchantApi\Handler\UpdateOrderHandler
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.command_handler }
|
||||
arguments:
|
||||
- '@inpost.izi.object_model.order_repository'
|
||||
- '@izi\prestashop\Configuration\OrdersConfiguration'
|
||||
- '@izi\prestashop\Builder\Order\OrderStatusDescriptionProvider'
|
||||
- '@inpost.izi.general_logger'
|
||||
|
||||
izi\prestashop\MerchantApi\Handler\Order\UpdateCartMessageHandlerInterface: '@izi\prestashop\MerchantApi\Handler\Order\UpdateCartMessageHandler'
|
||||
izi\prestashop\MerchantApi\Handler\Order\UpdateCartMessageHandler:
|
||||
class: izi\prestashop\MerchantApi\Handler\Order\UpdateCartMessageHandler
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.command_handler }
|
||||
arguments:
|
||||
- '@izi\prestashop\ObjectModel\ObjectManagerInterface'
|
||||
- '@izi\prestashop\Configuration\OrdersConfiguration'
|
||||
- '@izi\prestashop\Order\Message\MessageFormatterInterface'
|
||||
|
||||
izi\prestashop\MerchantApi\Handler\Basket\CreateCartHandlerInterface: '@izi\prestashop\MerchantApi\Handler\Basket\CreateCartHandler'
|
||||
izi\prestashop\MerchantApi\Handler\Basket\CreateCartHandler:
|
||||
class: izi\prestashop\MerchantApi\Handler\Basket\CreateCartHandler
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.command_handler }
|
||||
arguments:
|
||||
- '@inpost.izi.context'
|
||||
- '@izi\prestashop\Configuration\PrestaShopConfiguration'
|
||||
- '@izi\prestashop\ObjectModel\ObjectManagerInterface'
|
||||
|
||||
izi\prestashop\MerchantApi\Handler\Basket\AddProductToCartHandlerInterface: '@izi\prestashop\MerchantApi\Handler\Basket\AddProductToCartHandler'
|
||||
izi\prestashop\MerchantApi\Handler\Basket\AddProductToCartHandler:
|
||||
class: izi\prestashop\MerchantApi\Handler\Basket\AddProductToCartHandler
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.command_handler }
|
||||
arguments:
|
||||
- '@inpost.izi.context'
|
||||
- '@izi\prestashop\ObjectModel\Repository\ProductRepository'
|
||||
- '@izi\prestashop\Translation\LegacyTranslator'
|
||||
- '@inpost.izi.general_logger'
|
||||
|
||||
izi\prestashop\MerchantApi\Handler\Basket\IncrementCartQuantityHandlerInterface: '@izi\prestashop\MerchantApi\Handler\Basket\IncrementCartQuantityHandler'
|
||||
izi\prestashop\MerchantApi\Handler\Basket\IncrementCartQuantityHandler:
|
||||
class: izi\prestashop\MerchantApi\Handler\Basket\IncrementCartQuantityHandler
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.command_handler }
|
||||
arguments:
|
||||
- '@izi\prestashop\ObjectModel\Repository\ProductRepository'
|
||||
- '@izi\prestashop\Translation\LegacyTranslator'
|
||||
- '@inpost.izi.general_logger'
|
||||
|
||||
izi\prestashop\MerchantApi\Handler\Basket\BasketEventHandlerInterface: '@izi\prestashop\MerchantApi\Handler\Basket\BasketEventHandler'
|
||||
izi\prestashop\MerchantApi\Handler\Basket\BasketEventHandler:
|
||||
class: izi\prestashop\MerchantApi\Handler\Basket\BasketEventHandler
|
||||
public: false
|
||||
arguments:
|
||||
- '@inpost.izi.basket_event_handler_locator'
|
||||
- '@izi\prestashop\ContextManager'
|
||||
- '@izi\prestashop\Event\EventDispatcherInterface'
|
||||
|
||||
izi\prestashop\MerchantApi\Handler\Basket\ProductsQuantityEventHandler:
|
||||
class: izi\prestashop\MerchantApi\Handler\Basket\ProductsQuantityEventHandler
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.basket_event_handler }
|
||||
arguments:
|
||||
- '@inpost.izi.module'
|
||||
- '@inpost.izi.context'
|
||||
- '@izi\prestashop\ObjectModel\ObjectManager'
|
||||
- '@inpost.izi.general_logger'
|
||||
|
||||
izi\prestashop\MerchantApi\Handler\Basket\PromoCodesEventHandler:
|
||||
class: izi\prestashop\MerchantApi\Handler\Basket\PromoCodesEventHandler
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.basket_event_handler }
|
||||
arguments:
|
||||
- '@inpost.izi.module'
|
||||
- '@inpost.izi.context'
|
||||
- '@izi\prestashop\ObjectModel\ObjectManager'
|
||||
- '@inpost.izi.general_logger'
|
||||
|
||||
izi\prestashop\MerchantApi\Handler\Basket\RelatedProductsEventHandler:
|
||||
class: izi\prestashop\MerchantApi\Handler\Basket\RelatedProductsEventHandler
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.basket_event_handler }
|
||||
arguments:
|
||||
- '@izi\prestashop\CommandBusInterface'
|
||||
- '@inpost.izi.context'
|
||||
|
||||
izi\prestashop\MerchantApi\Firewall\MerchantApiAuthenticator:
|
||||
class: izi\prestashop\MerchantApi\Firewall\MerchantApiAuthenticator
|
||||
public: true # todo: make private after refactoring the front controller
|
||||
arguments:
|
||||
- '@izi\prestashop\MerchantApi\Firewall\SigningKeysService'
|
||||
- '@inpost.izi.clock'
|
||||
|
||||
izi\prestashop\MerchantApi\Firewall\SigningKeysService:
|
||||
class: izi\prestashop\MerchantApi\Firewall\SigningKeysService
|
||||
public: false
|
||||
arguments:
|
||||
- '@izi\prestashop\BasketApp\Signature\SigningKeysApiClientInterface'
|
||||
- '@izi\prestashop\Cache\ConfigurationCache'
|
||||
|
||||
inpost.izi.security.access.decision_manager:
|
||||
class: Symfony\Component\Security\Core\Authorization\AccessDecisionManager
|
||||
public: false
|
||||
arguments:
|
||||
- !tagged inpost.izi.security_voter
|
||||
|
||||
inpost.izi.security.authorization_checker:
|
||||
class: izi\prestashop\Security\AuthorizationChecker
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.widget_controller_dependency, key: Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface }
|
||||
arguments:
|
||||
- '@inpost.izi.security.access.decision_manager'
|
||||
|
||||
izi\prestashop\Security\Voter\BindingWidgetVoter:
|
||||
class: izi\prestashop\Security\Voter\BindingWidgetVoter
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.security_voter }
|
||||
arguments:
|
||||
- '@izi\prestashop\Configuration\GeneralConfigurationInterface'
|
||||
- '@inpost.izi.context'
|
||||
|
||||
izi\prestashop\View\Asset\Provider\Front\CommonAssetsProvider:
|
||||
class: izi\prestashop\View\Asset\Provider\Front\CommonAssetsProvider
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.front_assets_provider }
|
||||
arguments:
|
||||
- '@inpost.izi.module'
|
||||
- '@inpost.izi.context'
|
||||
- '@inpost.izi.environment'
|
||||
|
||||
izi\prestashop\View\Asset\Provider\Front\ProductPageAssetsProvider:
|
||||
class: izi\prestashop\View\Asset\Provider\Front\ProductPageAssetsProvider
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.front_assets_provider }
|
||||
arguments:
|
||||
- '@izi\prestashop\Configuration\GeneralConfigurationInterface'
|
||||
- '@inpost.izi.context'
|
||||
|
||||
izi\prestashop\View\Asset\Provider\Front\WidgetConfigurationProvider:
|
||||
class: izi\prestashop\View\Asset\Provider\Front\WidgetConfigurationProvider
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.front_assets_provider }
|
||||
arguments:
|
||||
- '@inpost.izi.context'
|
||||
- '@izi\prestashop\Configuration\ApiConfigurationInterface'
|
||||
- '@izi\prestashop\Configuration\GeneralConfigurationInterface'
|
||||
- '@izi\prestashop\Repository\BasketSessionRepository'
|
||||
|
||||
izi\prestashop\Order\ContextCustomerUpdater:
|
||||
class: izi\prestashop\Order\ContextCustomerUpdater
|
||||
public: false
|
||||
arguments:
|
||||
- '@inpost.izi.context'
|
||||
- '@izi\prestashop\ObjectModel\ObjectManagerInterface'
|
||||
131
modules/inpostizi/config/services/sf28.yml
Normal file
131
modules/inpostizi/config/services/sf28.yml
Normal file
@@ -0,0 +1,131 @@
|
||||
# PS < 1.7.4 configuration
|
||||
imports:
|
||||
- { resource: common.yml }
|
||||
- { resource: common_admin.yml }
|
||||
- { resource: common_front.yml }
|
||||
|
||||
parameters:
|
||||
inpost.izi.logs_dir: '%kernel.root_dir%/logs/inpost'
|
||||
|
||||
services:
|
||||
inpost.izi.event_dispatcher:
|
||||
class: Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher
|
||||
public: false
|
||||
arguments:
|
||||
- '@service_container'
|
||||
|
||||
izi\prestashop\CommandBus:
|
||||
class: izi\prestashop\CommandBus
|
||||
arguments:
|
||||
- '@inpost.izi.command_handler_locator'
|
||||
|
||||
inpost.izi.command_handler_locator:
|
||||
class: izi\prestashop\DependencyInjection\ServiceLocator
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: inpost.izi.service_locator, tag: inpost.izi.command_handler, index_by: command_class, default_index_method: getHandledCommandClass }
|
||||
|
||||
izi\prestashop\Hook\HookExecutor:
|
||||
class: izi\prestashop\Hook\HookExecutor
|
||||
arguments:
|
||||
- '@inpost.izi.hook_locator'
|
||||
- '@inpost.izi.module'
|
||||
|
||||
inpost.izi.hook_locator:
|
||||
class: izi\prestashop\DependencyInjection\ServiceLocator
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: inpost.izi.service_locator, tag: inpost.izi.hook, index_by: hook_name, default_index_method: getHookName }
|
||||
|
||||
inpost.izi.repository_locator:
|
||||
class: izi\prestashop\DependencyInjection\ServiceLocator
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: inpost.izi.service_locator, tag: inpost.izi.model_repository, index_by: model_class }
|
||||
|
||||
inpost.izi.basket_event_handler_locator:
|
||||
class: izi\prestashop\DependencyInjection\ServiceLocator
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: inpost.izi.service_locator, tag: inpost.izi.basket_event_handler, index_by: event_type, default_index_method: getHandledEventType }
|
||||
|
||||
izi\prestashop\Hook\Admin\ActionAdminCartRuleSaveAfter:
|
||||
class: izi\prestashop\Hook\Admin\ActionAdminCartRuleSaveAfter
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.hook }
|
||||
arguments:
|
||||
- '@inpost.izi.form_factory'
|
||||
- '@izi\prestashop\CommandBusInterface'
|
||||
|
||||
izi\prestashop\Hook\Admin\ActionAdminControllerSetMedia:
|
||||
class: izi\prestashop\Hook\Admin\ActionAdminControllerSetMedia
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.hook }
|
||||
arguments:
|
||||
- '@izi\prestashop\View\Asset\AdminAssetManager'
|
||||
- !tagged inpost.izi.admin_assets_provider
|
||||
|
||||
izi\prestashop\Hook\Admin\DisplayBackOfficeHeader:
|
||||
class: izi\prestashop\Hook\Admin\DisplayBackOfficeHeader
|
||||
public: false
|
||||
tags:
|
||||
- { name: inpost.izi.hook }
|
||||
arguments:
|
||||
- '@inpost.izi.context'
|
||||
- '@izi\prestashop\Repository\CartRuleRepositoryInterface'
|
||||
- '@inpost.izi.form_factory'
|
||||
- '@izi\prestashop\View\Templating\RendererInterface'
|
||||
|
||||
izi\prestashop\Hook\Admin\DisplayAdminOrderLeft:
|
||||
class: izi\prestashop\Hook\Admin\DisplayAdminOrderLeft
|
||||
public: false
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: inpost.izi.hook }
|
||||
|
||||
inpost.izi.constraint_validator_locator:
|
||||
class: izi\prestashop\DependencyInjection\ServiceLocator
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: inpost.izi.service_locator, tag: validator.constraint_validator }
|
||||
|
||||
inpost.izi.gui_configuration_locator:
|
||||
class: izi\prestashop\DependencyInjection\ServiceLocator
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: inpost.izi.service_locator, tag: inpost.izi.gui_configuration_dependency, index_by: key }
|
||||
|
||||
izi\prestashop\Form\FormFactoryFactory:
|
||||
class: izi\prestashop\Form\FormFactoryFactory
|
||||
public: false
|
||||
arguments:
|
||||
- '@inpost.izi.validator'
|
||||
|
||||
inpost.izi.form_factory:
|
||||
class: Symfony\Component\Form\FormFactoryInterface
|
||||
factory: [ '@izi\prestashop\Form\FormFactoryFactory', create ]
|
||||
public: false
|
||||
arguments:
|
||||
- '@inpost.izi.form_type_locator'
|
||||
-
|
||||
Symfony\Component\Form\Extension\Core\Type\ChoiceType: ['@izi\prestashop\Form\TypeExtension\ChoicesAsValuesTypeExtension']
|
||||
Symfony\Component\Form\Extension\Core\Type\FormType: ['@izi\prestashop\Form\TypeExtension\HelpTextExtension']
|
||||
|
||||
inpost.izi.form_type_locator:
|
||||
class: izi\prestashop\DependencyInjection\ServiceLocator
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: inpost.izi.service_locator, tag: form.type }
|
||||
|
||||
izi\prestashop\Form\TypeExtension\ChoicesAsValuesTypeExtension:
|
||||
class: izi\prestashop\Form\TypeExtension\ChoicesAsValuesTypeExtension
|
||||
tags:
|
||||
- { name: form.type_extension, extended_type: Symfony\Component\Form\Extension\Core\Type\ChoiceType }
|
||||
|
||||
inpost.izi.widget_controller_locator:
|
||||
class: izi\prestashop\DependencyInjection\ServiceLocator
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: inpost.izi.service_locator, tag: inpost.izi.widget_controller_dependency, index_by: key }
|
||||
72
modules/inpostizi/config/services/sf34.yml
Normal file
72
modules/inpostizi/config/services/sf34.yml
Normal file
@@ -0,0 +1,72 @@
|
||||
# PS >= 1.7.4 common FO/BO configuration
|
||||
imports:
|
||||
- { resource: common.yml }
|
||||
|
||||
services:
|
||||
_defaults:
|
||||
public: false
|
||||
|
||||
inpost.izi.repository_locator:
|
||||
class: Symfony\Component\DependencyInjection\ServiceLocator
|
||||
tags:
|
||||
- { name: container.service_locator }
|
||||
arguments:
|
||||
- Cart: '@inpost.izi.object_model.cart_repository'
|
||||
Country: '@inpost.izi.object_model.country_repository'
|
||||
Currency: '@izi\prestashop\ObjectModel\Repository\CurrencyRepository'
|
||||
Carrier: '@izi\prestashop\ObjectModel\Repository\CarrierRepository'
|
||||
CartRule: '@izi\prestashop\ObjectModel\Repository\CartRuleRepository'
|
||||
Combination: '@izi\prestashop\ObjectModel\Repository\CombinationRepository'
|
||||
Product: '@izi\prestashop\ObjectModel\Repository\ProductRepository'
|
||||
Configuration: '@izi\prestashop\ObjectModel\Repository\ConfigurationRepository'
|
||||
Hook: '@izi\prestashop\ObjectModel\Repository\HookRepository'
|
||||
Language: '@inpost.izi.object_model.language_repository'
|
||||
Order: '@inpost.izi.object_model.order_repository'
|
||||
OrderState: '@inpost.izi.object_model.order_state_repository'
|
||||
Shop: '@inpost.izi.object_model.shop_repository'
|
||||
InPostShipmentModel: '@izi\prestashop\ObjectModel\Repository\ShipmentRepository'
|
||||
|
||||
inpost.izi.event_dispatcher:
|
||||
class: Symfony\Component\EventDispatcher\EventDispatcherInterface
|
||||
factory: [ '@izi\prestashop\Event\EventDispatcherFactory', create ]
|
||||
|
||||
inpost.izi.event_subscriber_locator:
|
||||
class: Symfony\Component\DependencyInjection\ServiceLocator
|
||||
tags:
|
||||
- { name: container.service_locator }
|
||||
arguments:
|
||||
- izi\prestashop\EventListener\ShipmentListener: '@izi\prestashop\EventListener\ShipmentListener'
|
||||
izi\prestashop\EventListener\CartListener: '@izi\prestashop\EventListener\CartListener'
|
||||
izi\prestashop\EventListener\OrderListener: '@izi\prestashop\EventListener\OrderListener'
|
||||
izi\prestashop\Form\BasketAppClientProvider: '@?izi\prestashop\Form\BasketAppClientProvider'
|
||||
izi\prestashop\MerchantApi\EventListener\UpdateCartRulesListener: '@?izi\prestashop\MerchantApi\EventListener\UpdateCartRulesListener'
|
||||
izi\prestashop\HotProduct\EventListener\UpdateHotProductsListener: '@izi\prestashop\HotProduct\EventListener\UpdateHotProductsListener'
|
||||
izi\prestashop\EventListener\CreateShipmentListener: '@?izi\prestashop\EventListener\CreateShipmentListener'
|
||||
izi\prestashop\Mail\EventListener\ReplaceOrderNotificationRecipientListener: '@izi\prestashop\Mail\EventListener\ReplaceOrderNotificationRecipientListener'
|
||||
izi\prestashop\Analytics\EventListener\UpdateBasketAnalyticsListener: '@izi\prestashop\Analytics\EventListener\UpdateBasketAnalyticsListener'
|
||||
|
||||
izi\prestashop\Event\EventDispatcherFactory:
|
||||
class: izi\prestashop\Event\EventDispatcherFactory
|
||||
arguments:
|
||||
- '@inpost.izi.event_subscriber_locator'
|
||||
|
||||
inpost.izi.constraint_validator_locator:
|
||||
class: Symfony\Component\DependencyInjection\ServiceLocator
|
||||
tags: [ container.service_locator ]
|
||||
arguments:
|
||||
- izi\prestashop\Validator\Cart\BindableValidator: '@?izi\prestashop\Validator\Cart\BindableValidator'
|
||||
izi\prestashop\Validator\Cart\HasProductsValidator: '@?izi\prestashop\Validator\Cart\HasProductsValidator'
|
||||
izi\prestashop\Validator\Cart\PaymentInCurrencyAvailableValidator: '@?izi\prestashop\Validator\Cart\PaymentInCurrencyAvailableValidator'
|
||||
izi\prestashop\Validator\Product\NotInRestrictedCategoryValidator: '@izi\prestashop\Validator\Product\NotInRestrictedCategoryValidator'
|
||||
izi\prestashop\Validator\Product\NotFromRestrictedManufacturerValidator: '@izi\prestashop\Validator\Product\NotFromRestrictedManufacturerValidator'
|
||||
izi\prestashop\Validator\Product\NotWithRestrictedAttributesValidator: '@izi\prestashop\Validator\Product\NotWithRestrictedAttributesValidator'
|
||||
izi\prestashop\Validator\Product\NotWithRestrictedFeaturesValidator: '@izi\prestashop\Validator\Product\NotWithRestrictedFeaturesValidator'
|
||||
izi\prestashop\Validator\Product\UnrestrictedValidator: '@izi\prestashop\Validator\Product\UnrestrictedValidator'
|
||||
|
||||
inpost.izi.gui_configuration_locator:
|
||||
class: Symfony\Component\DependencyInjection\ServiceLocator
|
||||
tags: [ container.service_locator ]
|
||||
arguments:
|
||||
- validator: '@inpost.izi.validator'
|
||||
context: '@inpost.izi.shop_context'
|
||||
izi\prestashop\Repository\ProductRestrictionsRepositoryInterface: '@izi\prestashop\Repository\ProductRestrictionsRepositoryInterface'
|
||||
48
modules/inpostizi/config/webservice/services.yml
Normal file
48
modules/inpostizi/config/webservice/services.yml
Normal file
@@ -0,0 +1,48 @@
|
||||
imports:
|
||||
- { resource: ../services/sf34.yml }
|
||||
|
||||
services:
|
||||
izi\prestashop\CommandBus:
|
||||
class: izi\prestashop\CommandBus
|
||||
arguments:
|
||||
- '@inpost.izi.command_handler_locator'
|
||||
|
||||
inpost.izi.command_handler_locator:
|
||||
class: Symfony\Component\DependencyInjection\ServiceLocator
|
||||
tags: [ container.service_locator ]
|
||||
arguments:
|
||||
- izi\prestashop\Command\UpdateOrderTrackingNumbersCommand: '@izi\prestashop\Handler\UpdateOrderTrackingNumbersHandlerInterface'
|
||||
izi\prestashop\Command\UpdateOrderStatusCommand: '@izi\prestashop\Handler\UpdateOrderStatusHandlerInterface'
|
||||
izi\prestashop\Command\UpdateBasketCommand: '@izi\prestashop\Handler\UpdateBasketHandlerInterface'
|
||||
izi\prestashop\Command\UnbindBasketCommand: '@izi\prestashop\Handler\UnbindBasketHandlerInterface'
|
||||
izi\prestashop\Command\UpdateOrderAddressDeliveryCommand: '@izi\prestashop\Handler\UpdateOrderAddressDeliveryHandlerInterface'
|
||||
izi\prestashop\HotProduct\Message\DeleteRemoteProductCommand: '@izi\prestashop\HotProduct\MessageHandler\DeleteRemoteProductHandlerInterface'
|
||||
izi\prestashop\HotProduct\Message\UpdateHotProductCommand: '@izi\prestashop\HotProduct\MessageHandler\UpdateHotProductHandlerInterface'
|
||||
|
||||
inpost.izi.hook_locator:
|
||||
class: Symfony\Component\DependencyInjection\ServiceLocator
|
||||
tags: [ container.service_locator ]
|
||||
arguments:
|
||||
- actionObjectCartDeleteBefore: '@izi\prestashop\Hook\Common\ActionCartDeleteBefore'
|
||||
actionObjectCartUpdateAfter: '@izi\prestashop\Hook\Common\ActionCartUpdateAfter'
|
||||
actionObjectInPostShipmentModelAddAfter: '@izi\prestashop\Hook\Common\ActionShipmentAddAfter'
|
||||
actionObjectInPostShipmentModelUpdateBefore: '@izi\prestashop\Hook\Common\ActionShipmentUpdateBefore'
|
||||
actionObjectInPostShipmentModelUpdateAfter: '@izi\prestashop\Hook\Common\ActionShipmentUpdateAfter'
|
||||
actionValidateOrder: '@izi\prestashop\Hook\Common\ActionValidateOrder'
|
||||
actionOrderStatusPostUpdate: '@izi\prestashop\Hook\Common\ActionOrderStatusPostUpdate'
|
||||
actionObjectOrderUpdateBefore: '@izi\prestashop\Hook\Common\ActionObjectOrderUpdateBefore'
|
||||
actionObjectOrderUpdateAfter: '@izi\prestashop\Hook\Common\ActionObjectOrderUpdateAfter'
|
||||
actionEmailSendBefore: '@izi\prestashop\Hook\Common\ActionEmailSendBefore'
|
||||
# products
|
||||
actionObjectProductDeleteBefore: '@izi\prestashop\Hook\Common\Product\ActionProductDeleteBefore'
|
||||
actionObjectProductDeleteAfter: '@izi\prestashop\Hook\Common\Product\ActionProductDeleteAfter'
|
||||
actionObjectProductUpdateAfter: '@izi\prestashop\Hook\Common\Product\ActionProductUpdateAfter'
|
||||
actionObjectCombinationDeleteBefore: '@izi\prestashop\Hook\Common\Product\ActionCombinationDeleteBefore'
|
||||
actionObjectCombinationDeleteAfter: '@izi\prestashop\Hook\Common\Product\ActionCombinationDeleteAfter'
|
||||
actionObjectCombinationUpdateAfter: '@izi\prestashop\Hook\Common\Product\ActionCombinationUpdateAfter'
|
||||
actionObjectImageAddAfter: '@izi\prestashop\Hook\Common\Product\ActionImageAddAfter'
|
||||
actionObjectImageDeleteAfter: '@izi\prestashop\Hook\Common\Product\ActionImageDeleteAfter'
|
||||
actionObjectSpecificPriceAddAfter: '@izi\prestashop\Hook\Common\Product\ActionSpecificPriceAddAfter'
|
||||
actionObjectSpecificPriceUpdateAfter: '@izi\prestashop\Hook\Common\Product\ActionSpecificPriceUpdateAfter'
|
||||
actionObjectSpecificPriceDeleteAfter: '@izi\prestashop\Hook\Common\Product\ActionSpecificPriceDeleteAfter'
|
||||
actionUpdateQuantity: '@izi\prestashop\Hook\Common\Product\ActionUpdateQuantity'
|
||||
12
modules/inpostizi/config_pl.xml
Normal file
12
modules/inpostizi/config_pl.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<module>
|
||||
<name>inpostizi</name>
|
||||
<displayName><![CDATA[InPost Pay]]></displayName>
|
||||
<version><![CDATA[2.2.3]]></version>
|
||||
<description><![CDATA[]]></description>
|
||||
<author><![CDATA[InPost S.A.]]></author>
|
||||
<tab><![CDATA[payments_gateways]]></tab>
|
||||
<is_configurable>1</is_configurable>
|
||||
<need_instance>1</need_instance>
|
||||
<limited_countries></limited_countries>
|
||||
</module>
|
||||
421
modules/inpostizi/controllers/front/backend.php
Normal file
421
modules/inpostizi/controllers/front/backend.php
Normal file
@@ -0,0 +1,421 @@
|
||||
<?php
|
||||
|
||||
use izi\prestashop\BasketApp\Exception\BasketAppException;
|
||||
use izi\prestashop\Controller\Api\BasketController;
|
||||
use izi\prestashop\Controller\Api\OrderController;
|
||||
use izi\prestashop\Controller\Api\ProductController;
|
||||
use izi\prestashop\Controller\WidgetController;
|
||||
use izi\prestashop\Http\Client\ModuleVersionInfoProvidingClient;
|
||||
use izi\prestashop\Http\Exception\HttpExceptionInterface;
|
||||
use izi\prestashop\Http\Exception\ServerException;
|
||||
use izi\prestashop\MerchantApi\Exception\ApiException;
|
||||
use izi\prestashop\MerchantApi\Exception\BadGatewayException;
|
||||
use izi\prestashop\MerchantApi\Exception\InternalServerErrorException;
|
||||
use izi\prestashop\MerchantApi\Exception\ServiceUnavailableException;
|
||||
use izi\prestashop\MerchantApi\Firewall\MerchantApiAuthenticator;
|
||||
use izi\prestashop\OAuth2\Exception\OAuth2ExceptionInterface;
|
||||
use Psr\Http\Client\NetworkExceptionInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Psr\Log\LogLevel;
|
||||
use Symfony\Component\Debug\ErrorHandler as LegacyErrorHandler;
|
||||
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
|
||||
use Symfony\Component\ErrorHandler\ErrorHandler;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class InpostIziBackendModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
private const MERCHANT_ROUTES = [
|
||||
[
|
||||
'path' => '/inpost/v2/izi/merchant/basket/binding-key',
|
||||
'methods' => ['GET'],
|
||||
'controller' => [WidgetController::class, 'getBindingKey'],
|
||||
],
|
||||
[
|
||||
'path' => '/inpost/v2/izi/merchant/order/confirmation-url',
|
||||
'methods' => ['GET'],
|
||||
'controller' => [WidgetController::class, 'getOrderConfirmationUrl'],
|
||||
],
|
||||
];
|
||||
|
||||
private const API_ROUTES = [
|
||||
[
|
||||
'path' => '/inpost/v1/izi/products',
|
||||
'methods' => ['GET'],
|
||||
'controller' => [ProductController::class, 'getProducts'],
|
||||
],
|
||||
[
|
||||
'path' => '/inpost/v1/izi/order',
|
||||
'methods' => ['POST'],
|
||||
'controller' => [OrderController::class, 'create'],
|
||||
],
|
||||
[
|
||||
'path' => '/inpost/v1/izi/order/{orderId}',
|
||||
'methods' => ['GET'],
|
||||
'prefix' => '/inpost/v1/izi/order/',
|
||||
'regex' => '#^/inpost/v1/izi/order/(?<orderId>\d+)$#',
|
||||
'controller' => [OrderController::class, 'get'],
|
||||
],
|
||||
[
|
||||
'path' => '/inpost/v1/izi/order/{orderId}/event',
|
||||
'methods' => ['POST'],
|
||||
'prefix' => '/inpost/v1/izi/order/',
|
||||
'regex' => '#^/inpost/v1/izi/order/(?<orderId>\d+)/event$#',
|
||||
'controller' => [OrderController::class, 'update'],
|
||||
],
|
||||
[
|
||||
'path' => '/inpost/v1/izi/basket/{basketId}',
|
||||
'methods' => ['GET'],
|
||||
'prefix' => '/inpost/v1/izi/basket/',
|
||||
'regex' => '#^/inpost/v1/izi/basket/(?<basketId>.+)$#',
|
||||
'controller' => [BasketController::class, 'get'],
|
||||
],
|
||||
[
|
||||
'path' => '/inpost/v1/izi/basket/{basketId}/confirmation',
|
||||
'methods' => ['POST'],
|
||||
'prefix' => '/inpost/v1/izi/basket/',
|
||||
'regex' => '#^/inpost/v1/izi/basket/(?<basketId>.+)/confirmation$#',
|
||||
'controller' => [BasketController::class, 'confirm'],
|
||||
],
|
||||
[
|
||||
'path' => '/inpost/v1/izi/basket/{basketId}/event',
|
||||
'methods' => ['POST'],
|
||||
'prefix' => '/inpost/v1/izi/basket/',
|
||||
'regex' => '#^/inpost/v1/izi/basket/(?<basketId>.+)/event$#',
|
||||
'controller' => [BasketController::class, 'update'],
|
||||
],
|
||||
[
|
||||
'path' => '/inpost/v1/izi/basket/{basketId}/binding',
|
||||
'methods' => ['DELETE'],
|
||||
'prefix' => '/inpost/v1/izi/basket/',
|
||||
'regex' => '#^/inpost/v1/izi/basket/(?<basketId>.+)/binding$#',
|
||||
'controller' => [BasketController::class, 'deleteBinding'],
|
||||
],
|
||||
[
|
||||
'path' => '/inpost/v1/izi/basket/{basketId}/binding/delete',
|
||||
'methods' => ['POST'],
|
||||
'prefix' => '/inpost/v1/izi/basket/',
|
||||
'regex' => '#^/inpost/v1/izi/basket/(?<basketId>.+)/binding/delete$#',
|
||||
'controller' => [BasketController::class, 'deleteBinding'],
|
||||
],
|
||||
[
|
||||
'path' => '/inpost/v1/izi/basket/product/{productId}',
|
||||
'methods' => ['POST'],
|
||||
'prefix' => '/inpost/v1/izi/basket/product/',
|
||||
'regex' => '#^/inpost/v1/izi/basket/product/(?<productId>.+)$#',
|
||||
'controller' => [BasketController::class, 'addProduct'],
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* @var InPostIzi
|
||||
*/
|
||||
public $module;
|
||||
|
||||
protected $content_only = true;
|
||||
|
||||
private $outputBuffer = '';
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
$this->registerErrorHandler();
|
||||
ob_start([$this, 'handleOutput'], 1);
|
||||
|
||||
$request = $this->module->getCurrentRequest();
|
||||
$request->attributes->set('_inpost_izi_shop_id', (int) $this->context->shop->id);
|
||||
|
||||
$response = $this->handle($request);
|
||||
Response::closeOutputBuffers(0, false);
|
||||
$response->send();
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Country $defaultCountry
|
||||
*/
|
||||
protected function geolocationManagement($defaultCountry): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function displayRestrictedCountryPage(): void
|
||||
{
|
||||
}
|
||||
|
||||
// TODO use own Sf Kernel?
|
||||
private function handle(Request $request): Response
|
||||
{
|
||||
$path = $this->getPath($request);
|
||||
|
||||
try {
|
||||
if (!str_contains($path, '/merchant/')) {
|
||||
return $this->handleApiRequest($request, $path);
|
||||
}
|
||||
|
||||
$response = $this->handleCustomerRequest($request, $path);
|
||||
$response->prepare($request);
|
||||
|
||||
$this->context->cookie->write();
|
||||
|
||||
return $response;
|
||||
} catch (Throwable $throwable) {
|
||||
http_response_code(500);
|
||||
$this->logError($throwable);
|
||||
|
||||
throw $throwable;
|
||||
}
|
||||
}
|
||||
|
||||
private function handleCustomerRequest(Request $request, string $path): Response
|
||||
{
|
||||
[$controller, $params] = $this->resolveController($request, $path, self::MERCHANT_ROUTES);
|
||||
|
||||
return null === $controller
|
||||
? $this->createNotFoundResponse($request, $path)
|
||||
: $this->callController($controller, $request, $params);
|
||||
}
|
||||
|
||||
private function handleApiRequest(Request $request, string $path): Response
|
||||
{
|
||||
$method = $request->getMethod();
|
||||
|
||||
/** @var LoggerInterface $logger */
|
||||
$logger = $this->module->get('inpost.izi.merchant_api_logger');
|
||||
$logger->info('Request "{method} {path}"', [
|
||||
'method' => $method,
|
||||
'path' => $path,
|
||||
]);
|
||||
|
||||
if ($body = $request->getContent()) {
|
||||
$logger->debug('Request body: "{body}"', ['body' => $body]);
|
||||
}
|
||||
|
||||
try {
|
||||
$this->module->get(MerchantApiAuthenticator::class)->authenticate($request);
|
||||
[$controller, $params] = $this->resolveController($request, $path, self::API_ROUTES);
|
||||
|
||||
/** @var JsonResponse $response */
|
||||
$response = null === $controller
|
||||
? $this->createNotFoundResponse($request, $path, true)
|
||||
: $this->callController($controller, $request, $params);
|
||||
} catch (Throwable $throwable) {
|
||||
$response = $this->handleApiError($throwable);
|
||||
}
|
||||
|
||||
$logger->info('Response "{method} {path}": {status_code}', [
|
||||
'method' => $method,
|
||||
'path' => $path,
|
||||
'status_code' => $response->getStatusCode(),
|
||||
]);
|
||||
|
||||
if (!$response->isSuccessful()) {
|
||||
$logger->error('Response body: "{body}"', ['body' => $response->getContent()]);
|
||||
} elseif ($body = $response->getContent()) {
|
||||
$logger->debug('Response body: "{body}"', ['body' => $body]);
|
||||
}
|
||||
|
||||
$response->headers->set(ModuleVersionInfoProvidingClient::HEADER_NAME, $this->module->version);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
private function handleApiError(Throwable $throwable): Response
|
||||
{
|
||||
$exception = $this->convertApiError($throwable);
|
||||
|
||||
if ($exception instanceof InternalServerErrorException && $previous = $exception->getPrevious()) {
|
||||
$this->logError($previous);
|
||||
}
|
||||
|
||||
return new JsonResponse([
|
||||
'error_code' => $exception->getErrorCode(),
|
||||
'error_message' => $exception->getMessage(),
|
||||
], $exception->getStatusCode());
|
||||
}
|
||||
|
||||
private function convertApiError(Throwable $throwable): ApiException
|
||||
{
|
||||
if ($throwable instanceof ApiException) {
|
||||
return $throwable;
|
||||
}
|
||||
|
||||
if ($throwable instanceof NetworkExceptionInterface) {
|
||||
$message = $throwable instanceof OAuth2ExceptionInterface
|
||||
? 'Could not connect to the authorization server'
|
||||
: 'Could not connect to the basket app API';
|
||||
|
||||
return BadGatewayException::create($throwable, $message);
|
||||
}
|
||||
|
||||
if ($throwable instanceof OAuth2ExceptionInterface) {
|
||||
return BadGatewayException::create($throwable, 'Could not obtain access token');
|
||||
}
|
||||
|
||||
if ($throwable instanceof BasketAppException) {
|
||||
return BadGatewayException::create($throwable, sprintf('Basket app API error: "%s"', $throwable->getError()->getCode()));
|
||||
}
|
||||
|
||||
if ($throwable instanceof ServerException && 503 === $throwable->getCode()) {
|
||||
return ServiceUnavailableException::create($throwable, 'Basket app API is unavailable');
|
||||
}
|
||||
|
||||
if ($throwable instanceof HttpExceptionInterface) {
|
||||
return BadGatewayException::create($throwable, sprintf('Unexpected basket app API response status code: %d', $throwable->getCode()));
|
||||
}
|
||||
|
||||
return InternalServerErrorException::create($throwable);
|
||||
}
|
||||
|
||||
private function getPath(Request $request): string
|
||||
{
|
||||
if (null === $path = $request->query->get('path')) {
|
||||
return '/';
|
||||
}
|
||||
|
||||
$path = rawurldecode($path);
|
||||
|
||||
if ('/' !== $path[0]) {
|
||||
$path = '/' . $path;
|
||||
}
|
||||
|
||||
return rtrim($path, '/');
|
||||
}
|
||||
|
||||
private function logError(Throwable $throwable): void
|
||||
{
|
||||
$this->module->getLogger()->error('Error processing request: {error}', ['error' => $throwable]);
|
||||
}
|
||||
|
||||
private function resolveController(Request $request, string $path, array $routes): array
|
||||
{
|
||||
$method = $request->getMethod();
|
||||
|
||||
foreach ($routes as $route) {
|
||||
if (isset($route['methods']) && !in_array($method, $route['methods'], true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isset($route['prefix']) && !str_starts_with($path, $route['prefix'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($route['regex']) && $path !== $route['path']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isset($route['regex']) && !preg_match($route['regex'], $path, $params)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return [$route['controller'], $params ?? []];
|
||||
}
|
||||
|
||||
return [null, []];
|
||||
}
|
||||
|
||||
private function callController(array $controller, Request $request, array $pathParams): Response
|
||||
{
|
||||
$arguments = $this->resolveControllerArguments($controller, $request, $pathParams);
|
||||
$controller = [$this->createController($controller[0]), $controller[1]];
|
||||
|
||||
return $controller(...$arguments);
|
||||
}
|
||||
|
||||
private function createController(string $className)
|
||||
{
|
||||
try {
|
||||
return $this->module->get($className);
|
||||
} catch (ServiceNotFoundException $e) {
|
||||
return new $className();
|
||||
}
|
||||
}
|
||||
|
||||
private function resolveControllerArguments(array $controller, Request $request, array $pathParams): array
|
||||
{
|
||||
$reflection = new ReflectionMethod($controller[0], $controller[1]);
|
||||
|
||||
return array_map(function (ReflectionParameter $param) use ($request, $pathParams) {
|
||||
return $this->resolveControllerArgument($param, $request, $pathParams);
|
||||
}, $reflection->getParameters());
|
||||
}
|
||||
|
||||
private function resolveControllerArgument(ReflectionParameter $param, Request $request, array $pathParams)
|
||||
{
|
||||
$type = $param->getType();
|
||||
|
||||
if (null !== $type && Request::class === $type->getName()) {
|
||||
return $request;
|
||||
}
|
||||
|
||||
$paramName = $param->getName();
|
||||
|
||||
if (isset($pathParams[$paramName])) {
|
||||
return $pathParams[$paramName];
|
||||
}
|
||||
|
||||
if ($param->isDefaultValueAvailable()) {
|
||||
return $param->getDefaultValue();
|
||||
}
|
||||
|
||||
throw new LogicException(sprintf('Cannot determine controller parameter value for argument "%s".', $paramName));
|
||||
}
|
||||
|
||||
private function createNotFoundResponse(Request $request, string $path, bool $json = false): Response
|
||||
{
|
||||
$message = sprintf('No route found for "%s %s"', $request->getMethod(), $path);
|
||||
|
||||
return $json || in_array('application/json', $request->getAcceptableContentTypes(), true)
|
||||
? new JsonResponse([
|
||||
'error_code' => 'NOT_FOUND',
|
||||
'error_message' => $message,
|
||||
], 404)
|
||||
: new Response($message, 404);
|
||||
}
|
||||
|
||||
private function registerErrorHandler(): void
|
||||
{
|
||||
$handler = class_exists(ErrorHandler::class)
|
||||
? ErrorHandler::register()
|
||||
: LegacyErrorHandler::register();
|
||||
|
||||
$handler->throwAt(E_ERROR, true);
|
||||
$handler->setDefaultLogger($this->module->getLogger(), [
|
||||
E_DEPRECATED => LogLevel::DEBUG,
|
||||
E_NOTICE => LogLevel::DEBUG,
|
||||
E_STRICT => LogLevel::DEBUG,
|
||||
E_WARNING => LogLevel::DEBUG,
|
||||
E_USER_WARNING => LogLevel::DEBUG,
|
||||
E_USER_ERROR => LogLevel::CRITICAL,
|
||||
E_RECOVERABLE_ERROR => LogLevel::CRITICAL,
|
||||
E_ERROR => LogLevel::CRITICAL,
|
||||
]);
|
||||
}
|
||||
|
||||
private function handleOutput(string $buffer, int $phase): string
|
||||
{
|
||||
if (PHP_OUTPUT_HANDLER_FINAL & $phase && '' !== $this->outputBuffer) {
|
||||
$this->module->getLogger()->warning('Output buffer content: "{buffer}".', [
|
||||
'buffer' => $this->outputBuffer,
|
||||
]);
|
||||
|
||||
$this->outputBuffer = '';
|
||||
}
|
||||
|
||||
if ('' === $buffer) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$this->outputBuffer .= $buffer;
|
||||
|
||||
if (PHP_OUTPUT_HANDLER_START & $phase) {
|
||||
$this->module->getLogger()->warning(sprintf(
|
||||
"Output started before sending response.\n[stacktrace]\n%s\n",
|
||||
(new \Exception())->getTraceAsString()
|
||||
));
|
||||
}
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
}
|
||||
644
modules/inpostizi/inpostizi.php
Normal file
644
modules/inpostizi/inpostizi.php
Normal file
@@ -0,0 +1,644 @@
|
||||
<?php
|
||||
|
||||
use izi\prestashop\AdminKernel;
|
||||
use izi\prestashop\Common\Currency;
|
||||
use izi\prestashop\Configuration\AdvancedConfigurationInterface;
|
||||
use izi\prestashop\DependencyInjection\Compiler\AnalyzeServiceReferencesPass;
|
||||
use izi\prestashop\DependencyInjection\Compiler\ProvideServiceLocatorFactoriesPass;
|
||||
use izi\prestashop\DependencyInjection\Compiler\TaggedIteratorsCollectorPass;
|
||||
use izi\prestashop\DependencyInjection\ContainerFactory;
|
||||
use izi\prestashop\DependencyInjection\Exception\ContainerNotFoundException;
|
||||
use izi\prestashop\Hook\Exception\HookNotFoundException;
|
||||
use izi\prestashop\Hook\Exception\HookNotImplementedException;
|
||||
use izi\prestashop\Hook\HookExecutor;
|
||||
use izi\prestashop\Hook\HookExecutorInterface;
|
||||
use izi\prestashop\Installer\DatabaseInstaller;
|
||||
use izi\prestashop\Module\Exception\ModuleErrorInterface;
|
||||
use PrestaShop\PrestaShop\Adapter\ContainerBuilder as PrestaShopContainerBuilder;
|
||||
use PrestaShop\PrestaShop\Adapter\SymfonyContainer;
|
||||
use PrestaShop\PrestaShop\Core\Exception\ContainerNotFoundException as PrestaShopContainerNotFoundException;
|
||||
use PrestaShop\PrestaShop\Core\Module\WidgetInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Config\Resource\FileResource;
|
||||
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
|
||||
use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\HttpFoundation\Session\Session;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Component\HttpKernel\TerminableInterface;
|
||||
use Symfony\Component\Routing\Exception\RouteNotFoundException;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if (file_exists(__DIR__ . '/vendor/autoload.php')) {
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
}
|
||||
|
||||
class InPostIzi extends PaymentModule implements WidgetInterface
|
||||
{
|
||||
private static $loggerServiceId = 'inpost.izi.general_logger';
|
||||
|
||||
/**
|
||||
* @var ContainerInterface|null
|
||||
*/
|
||||
private $legacyContainer;
|
||||
|
||||
/**
|
||||
* @var KernelInterface|null
|
||||
*/
|
||||
private $adminKernel;
|
||||
|
||||
/**
|
||||
* @var RequestStack
|
||||
*/
|
||||
private $requestStack;
|
||||
|
||||
/**
|
||||
* @var WidgetInterface
|
||||
*/
|
||||
private $widget;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->name = 'inpostizi';
|
||||
$this->version = '2.2.3';
|
||||
$this->author = 'InPost S.A.';
|
||||
$this->tab = 'payments_gateways';
|
||||
|
||||
$this->ps_versions_compliancy = [
|
||||
'min' => '1.7.1.0',
|
||||
'max' => '8.2.99',
|
||||
];
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->displayName = $this->l('InPost Pay');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
public function isUsingNewTranslationSystem()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function install()
|
||||
{
|
||||
if (70103 > PHP_VERSION_ID) {
|
||||
$this->_errors[] = $this->l('This module requires PHP 7.1.3 or later.');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
(new DatabaseInstaller())->install($this);
|
||||
} catch (Exception $e) {
|
||||
$this->_errors[] = $this->l('Could not update the database schema.');
|
||||
$this->getLogger()->critical('Installer error: {exception}.', [
|
||||
'exception' => $e,
|
||||
]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->setUpRoutingLoaderResolver();
|
||||
|
||||
return parent::install()
|
||||
&& $this->registerHook(HookExecutor::getHooksToInstall(_PS_VERSION_));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function uninstall()
|
||||
{
|
||||
$this->setUpRoutingLoaderResolver();
|
||||
|
||||
return parent::uninstall();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function runUpgradeModule()
|
||||
{
|
||||
try {
|
||||
$result = parent::runUpgradeModule();
|
||||
|
||||
if (!$result['available_upgrade']) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ($result['success']) {
|
||||
$this->getLogger()->info('Upgraded module to version {version}.', [
|
||||
'version' => $result['upgraded_to'],
|
||||
]);
|
||||
} else {
|
||||
$this->getLogger()->error('Could not upgrade module.', [
|
||||
'details' => $result,
|
||||
]);
|
||||
}
|
||||
|
||||
return $result;
|
||||
} catch (Throwable $e) {
|
||||
$this->getLogger()->critical('Upgrade error: {exception}.', [
|
||||
'exception' => $e,
|
||||
]);
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int[] $shops shop IDs
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function addCheckboxCurrencyRestrictionsForModule(array $shops = [])
|
||||
{
|
||||
if ([] === $shops) {
|
||||
$shops = Shop::getShops(true, null, true);
|
||||
}
|
||||
|
||||
$data = [];
|
||||
|
||||
foreach ($shops as $shopId) {
|
||||
foreach (Currency::cases() as $currency) {
|
||||
if (0 >= $currencyId = (int) \Currency::getIdByIsoCode($currency->value, $shopId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$data[] = [
|
||||
'id_module' => (int) $this->id,
|
||||
'id_shop' => (int) $shopId,
|
||||
'id_currency' => $currencyId,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return Db::getInstance()->insert('module_currency', $data);
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
if ($this->isContainerCacheStale() && $this->isContainerConfigLoaded()) {
|
||||
$this->clearCacheAndRedirectBackToConfigPage();
|
||||
}
|
||||
|
||||
try {
|
||||
/** @var UrlGeneratorInterface $router */
|
||||
$router = $this->get('router');
|
||||
|
||||
Tools::redirectAdmin($router->generate('admin_inpost_izi_config_general'));
|
||||
} catch (ServiceNotFoundException $e) {
|
||||
$this->handleConfigPageRequest();
|
||||
} catch (RouteNotFoundException $e) {
|
||||
if ($this->isContainerConfigLoaded()) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$this->addFlash($this->l('To access the configuration page, the module must be active.'));
|
||||
Tools::redirectAdmin($router->generate('admin_module_manage'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles hook calls.
|
||||
*
|
||||
* @param string $methodName
|
||||
*
|
||||
* @return mixed hook result
|
||||
*/
|
||||
public function __call($methodName, array $arguments)
|
||||
{
|
||||
$hookName = 0 === strpos($methodName, 'hook')
|
||||
? lcfirst(Tools::substr($methodName, 4))
|
||||
: $methodName;
|
||||
|
||||
try {
|
||||
$parameters = $this->normalizeHookParameters(isset($arguments[0]) ? $arguments[0] : []);
|
||||
|
||||
return $this
|
||||
->get(HookExecutorInterface::class)
|
||||
->execute($hookName, $parameters);
|
||||
} catch (ModuleErrorInterface $e) {
|
||||
throw $e;
|
||||
} catch (HookNotImplementedException $e) {
|
||||
$this->getLogger()->warning('Hook "{hookName}" is not implemented.', [
|
||||
'hookName' => $e->getHookName(),
|
||||
]);
|
||||
|
||||
return null;
|
||||
} catch (Throwable $e) {
|
||||
if ($this->isContainerCacheRelated($e)) {
|
||||
$this->getLogger()->error('Error executing hook "{hookName}": container cache is stale.', [
|
||||
'hookName' => $hookName,
|
||||
]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->getLogger()->critical('Error executing hook "{hookName}": {exception}', [
|
||||
'hookName' => $hookName,
|
||||
'exception' => $e,
|
||||
]);
|
||||
|
||||
if (_PS_MODE_DEV_ && $this->isDebugEnabled()) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
*
|
||||
* @param string|class-string<T> $serviceName
|
||||
*
|
||||
* @phpstan-return ($serviceName is class-string<T> ? T : object)
|
||||
*
|
||||
* @return T|object
|
||||
*/
|
||||
public function get($serviceName)
|
||||
{
|
||||
return $this->doGetContainer()->get($serviceName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $hookName
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function renderWidget($hookName, array $configuration)
|
||||
{
|
||||
$configuration = $this->normalizeHookParameters($configuration);
|
||||
|
||||
return $this->getWidget()->renderWidget($hookName, $configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $hookName
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getWidgetVariables($hookName, array $configuration)
|
||||
{
|
||||
$configuration = $this->normalizeHookParameters($configuration);
|
||||
|
||||
return $this->getWidget()->getWidgetVariables($hookName, $configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Request
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function getCurrentRequest()
|
||||
{
|
||||
return $this->getRequestStack()->getCurrentRequest() ?: Request::createFromGlobals();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return RequestStack
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function getRequestStack()
|
||||
{
|
||||
if (isset($this->requestStack)) {
|
||||
return $this->requestStack;
|
||||
}
|
||||
|
||||
try {
|
||||
/** @var RequestStack $requestStack */
|
||||
$requestStack = $this->get('request_stack');
|
||||
if (null !== $requestStack->getCurrentRequest()) {
|
||||
return $this->requestStack = $requestStack;
|
||||
}
|
||||
} catch (ServiceNotFoundException $e) {
|
||||
}
|
||||
|
||||
$this->requestStack = new RequestStack();
|
||||
$this->requestStack->push(Request::createFromGlobals());
|
||||
|
||||
return $this->requestStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return LoggerInterface
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function getLogger()
|
||||
{
|
||||
try {
|
||||
return $this->get(self::$loggerServiceId);
|
||||
} catch (ContainerNotFoundException $e) {
|
||||
return $this->getLegacyContainer()->get(self::$loggerServiceId);
|
||||
} catch (Exception $e) {
|
||||
return new Psr\Log\NullLogger();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ContainerInterface
|
||||
*/
|
||||
private function doGetContainer()
|
||||
{
|
||||
if (Tools::version_compare(_PS_VERSION_, '1.7.6')) {
|
||||
return $this->getLegacyContainer();
|
||||
}
|
||||
|
||||
if (Tools::version_compare(_PS_VERSION_, '1.7.7')) {
|
||||
return $this->getPS176Container();
|
||||
}
|
||||
|
||||
if (null !== $container = SymfonyContainer::getInstance()) {
|
||||
return $container;
|
||||
}
|
||||
|
||||
try {
|
||||
return $this->getContainer();
|
||||
} catch (PrestaShopContainerNotFoundException $e) {
|
||||
return $this->getFrontOfficeLegacyContainer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ContainerInterface
|
||||
*/
|
||||
private function getLegacyContainer()
|
||||
{
|
||||
if (!isset($this->legacyContainer)) {
|
||||
$this->legacyContainer = $this->createContainer();
|
||||
}
|
||||
|
||||
return $this->legacyContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ContainerInterface
|
||||
*/
|
||||
private function createContainer()
|
||||
{
|
||||
$cacheDir = sprintf('%s/inpost/izi/', rtrim(_PS_CACHE_DIR_, '/'));
|
||||
|
||||
if (Tools::version_compare(_PS_VERSION_, '1.7.4')) {
|
||||
$className = sprintf('InPost\\Izi\\Container_%s', str_replace('.', '_', $this->version));
|
||||
$resources = $this->getSf28ConfigResources();
|
||||
} else {
|
||||
$type = $this->context->controller instanceof AdminControllerCore ? 'admin' : 'front';
|
||||
$className = sprintf('InPost\\Izi\\%sContainer_%s', ucfirst($type), str_replace('.', '_', $this->version));
|
||||
$resources = [sprintf('%s/config/%s/services.yml', rtrim($this->getLocalPath(), '/'), $type)];
|
||||
}
|
||||
|
||||
return (new ContainerFactory($cacheDir))->create($className, $resources);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return iterable
|
||||
*/
|
||||
private function getSf28ConfigResources()
|
||||
{
|
||||
yield sprintf('%s/config/services/sf28.yml', rtrim($this->getLocalPath(), '/'));
|
||||
yield static function (ContainerBuilder $container) {
|
||||
$container->addResource(new FileResource(__FILE__));
|
||||
$container->addCompilerPass(new RegisterListenersPass('inpost.izi.event_dispatcher'), PassConfig::TYPE_BEFORE_REMOVING);
|
||||
$container->addCompilerPass(new ProvideServiceLocatorFactoriesPass('inpost.izi.service_locator'));
|
||||
$container->addCompilerPass(new TaggedIteratorsCollectorPass());
|
||||
AnalyzeServiceReferencesPass::decorateRemovingPasses($container, 'inpost.izi.service_locator');
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Accesses the public "routing.loader" service to provide a @see \Symfony\Component\Config\Loader\LoaderResolverInterface
|
||||
* to the routing configuration loader used by @see \PrestaShop\PrestaShop\Adapter\Module\Tab\ModuleTabRegister
|
||||
*/
|
||||
private function setUpRoutingLoaderResolver()
|
||||
{
|
||||
if (Tools::version_compare(_PS_VERSION_, '1.7.7')) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->get('routing.loader');
|
||||
} catch (Exception $e) {
|
||||
// ignore silently
|
||||
}
|
||||
}
|
||||
|
||||
private function handleConfigPageRequest()
|
||||
{
|
||||
$request = $this->getCurrentRequest();
|
||||
$request->query->remove('controllerUri');
|
||||
|
||||
$kernel = $this->getAdminKernel();
|
||||
$response = $kernel->handle($request);
|
||||
|
||||
$this->context->cookie->write();
|
||||
$response->send();
|
||||
|
||||
if ($kernel instanceof TerminableInterface) {
|
||||
$kernel->terminate($request, $response);
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return KernelInterface
|
||||
*/
|
||||
private function getAdminKernel()
|
||||
{
|
||||
if (isset($this->adminKernel)) {
|
||||
return $this->adminKernel;
|
||||
}
|
||||
|
||||
global $kernel;
|
||||
|
||||
if (!$kernel instanceof KernelInterface) {
|
||||
throw new RuntimeException('PS application kernel instance was not found.');
|
||||
}
|
||||
|
||||
$this->adminKernel = new AdminKernel($kernel, _PS_VERSION_);
|
||||
$this->adminKernel->boot();
|
||||
|
||||
$psContainer = $kernel->getContainer();
|
||||
$this->adminKernel->getContainer()->set('prestashop.security.admin.provider', $psContainer->get('prestashop.security.admin.provider'));
|
||||
|
||||
// In some very early 1.7 versions, the session may not have yet been started by PS application.
|
||||
$psContainer->get('session')->start();
|
||||
|
||||
return $this->adminKernel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
private function isDebugEnabled()
|
||||
{
|
||||
try {
|
||||
return $this->get(AdvancedConfigurationInterface::class)->isDebugEnabled();
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@see \Module::get()} does not check if {@see \Controller::$container} is set on PS 1.7.6.
|
||||
*
|
||||
* @return ContainerInterface
|
||||
*/
|
||||
private function getPS176Container()
|
||||
{
|
||||
if (isset($this->context->container)) {
|
||||
return $this->context->container;
|
||||
}
|
||||
|
||||
if (null !== $container = SymfonyContainer::getInstance()) {
|
||||
return $container;
|
||||
}
|
||||
|
||||
if ($this->context->controller instanceof Controller && null !== $container = $this->context->controller->getContainer()) {
|
||||
return $container;
|
||||
}
|
||||
|
||||
return $this->getFrontOfficeLegacyContainer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Access container before {@see \FrontController::$container} is set in {@see \Controller::init()}.
|
||||
*
|
||||
* @return ContainerInterface
|
||||
*/
|
||||
private function getFrontOfficeLegacyContainer()
|
||||
{
|
||||
if (!$this->context->controller instanceof FrontController || !class_exists(PrestaShopContainerBuilder::class)) {
|
||||
throw ContainerNotFoundException::create();
|
||||
}
|
||||
|
||||
try {
|
||||
return PrestaShopContainerBuilder::getContainer('front', _PS_MODE_DEV_);
|
||||
} catch (Exception $e) {
|
||||
throw ContainerNotFoundException::create($e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function normalizeHookParameters(array $parameters)
|
||||
{
|
||||
if (!isset($parameters['request'])) {
|
||||
$parameters['request'] = $this->getCurrentRequest();
|
||||
}
|
||||
|
||||
if (!isset($parameters['cart'])) {
|
||||
$parameters['cart'] = $this->context->cart;
|
||||
}
|
||||
|
||||
return $parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return WidgetInterface
|
||||
*/
|
||||
private function getWidget()
|
||||
{
|
||||
if (isset($this->widget)) {
|
||||
return $this->widget;
|
||||
}
|
||||
|
||||
return $this->widget = $this->get('inpost.izi.widget');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
private function isContainerCacheRelated(Throwable $e)
|
||||
{
|
||||
if (!$e instanceof HookNotFoundException && !$e instanceof ServiceNotFoundException && !$e instanceof TypeError) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->isContainerCacheStale();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
private function isContainerCacheStale()
|
||||
{
|
||||
try {
|
||||
$container = $this->doGetContainer();
|
||||
} catch (ContainerNotFoundException $e) {
|
||||
return false; // fingers crossed
|
||||
}
|
||||
|
||||
if (!$container->hasParameter('inpost.izi.container_version')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->version !== $container->getParameter('inpost.izi.container_version');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool whether PS automatically loads the module's container configuration
|
||||
*/
|
||||
private function isContainerConfigLoaded()
|
||||
{
|
||||
if ($this->active) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Tools::version_compare(_PS_VERSION_, '8.0.0')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->hasShopAssociations();
|
||||
}
|
||||
|
||||
private function clearCacheAndRedirectBackToConfigPage()
|
||||
{
|
||||
if (Tools::getValue('cache_cleared')) {
|
||||
$this->addFlash($this->l('An attempt to clear the cache may have failed. Please try to clear the cache manually.'));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->getLogger()->warning('Container cache is stale, attempting to clear.');
|
||||
|
||||
Tools::clearSf2Cache();
|
||||
Tools::redirectAdmin($this->context->link->getAdminLink('AdminModules', true, null, [
|
||||
'configure' => $this->name,
|
||||
'cache_cleared' => true,
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
* @param string $type
|
||||
*/
|
||||
private function addFlash($message, $type = 'error')
|
||||
{
|
||||
try {
|
||||
/** @var Session $session */
|
||||
$session = $this->get('session');
|
||||
$session->getFlashBag()->add($type, $message);
|
||||
} catch (ServiceNotFoundException $e) {
|
||||
// ignore silently
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
modules/inpostizi/logo.png
Normal file
BIN
modules/inpostizi/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
BIN
modules/inpostizi/logo.webp
Normal file
BIN
modules/inpostizi/logo.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.0 KiB |
155
modules/inpostizi/src/AdminKernel.php
Normal file
155
modules/inpostizi/src/AdminKernel.php
Normal file
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop;
|
||||
|
||||
use izi\prestashop\DependencyInjection\Compiler\AnalyzeServiceReferencesPass;
|
||||
use izi\prestashop\DependencyInjection\Compiler\ProvideServiceLocatorFactoriesPass;
|
||||
use izi\prestashop\DependencyInjection\Compiler\TaggedIteratorsCollectorPass;
|
||||
use izi\prestashop\DependencyInjection\Dumper\PhpDumper;
|
||||
use PrestaShopBundle\PrestaShopBundle;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle;
|
||||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
|
||||
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
|
||||
use Symfony\Bundle\SecurityBundle\SecurityBundle;
|
||||
use Symfony\Bundle\TwigBundle\TwigBundle;
|
||||
use Symfony\Component\Config\ConfigCache;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
|
||||
use Symfony\Component\HttpKernel\Kernel;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollectionBuilder;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class AdminKernel extends Kernel
|
||||
{
|
||||
use MicroKernelTrait;
|
||||
|
||||
private $logDir;
|
||||
private $cacheDir;
|
||||
private $secret;
|
||||
private $psVersion;
|
||||
|
||||
private $prestaShopBundle;
|
||||
|
||||
public function __construct(KernelInterface $kernel, string $psVersion)
|
||||
{
|
||||
$this->rootDir = $kernel->getRootDir();
|
||||
$this->logDir = $kernel->getLogDir() . '/inpost/izi';
|
||||
$this->cacheDir = $kernel->getCacheDir() . '/inpost/izi';
|
||||
$this->secret = $kernel->getContainer()->getParameter('kernel.secret');
|
||||
|
||||
$this->psVersion = $psVersion;
|
||||
$this->name = 'inpostizi';
|
||||
|
||||
parent::__construct($kernel->getEnvironment(), $kernel->isDebug());
|
||||
}
|
||||
|
||||
public function registerBundles(): iterable
|
||||
{
|
||||
yield new FrameworkBundle();
|
||||
yield new TwigBundle();
|
||||
yield new SecurityBundle();
|
||||
|
||||
if (class_exists(SensioFrameworkExtraBundle::class)) {
|
||||
yield new SensioFrameworkExtraBundle();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @override for the purpose of locating Twig templates included by PS using legacy bundle path syntax.
|
||||
*/
|
||||
public function getBundle($name, $first = true)
|
||||
{
|
||||
if ('PrestaShopBundle' === $name) {
|
||||
$bundle = $this->getPrestaShopBundle();
|
||||
|
||||
return $first ? $bundle : [$bundle];
|
||||
}
|
||||
|
||||
return parent::getBundle(...func_get_args());
|
||||
}
|
||||
|
||||
public function getLogDir(): string
|
||||
{
|
||||
return $this->logDir;
|
||||
}
|
||||
|
||||
public function getCacheDir(): string
|
||||
{
|
||||
return $this->cacheDir;
|
||||
}
|
||||
|
||||
protected function configureRoutes(RouteCollectionBuilder $routes): void
|
||||
{
|
||||
$configDir = $this->getConfigDir();
|
||||
|
||||
$routes->import(sprintf('%s/routes.yml', $configDir));
|
||||
$routes->addRoute($this->getConfigIndexRoute(), 'admin_inpost_izi_config_general');
|
||||
}
|
||||
|
||||
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
|
||||
{
|
||||
$configDir = $this->getConfigDir();
|
||||
|
||||
$loader->load(sprintf('%s/services.yml', $configDir));
|
||||
$loader->load(__DIR__ . '/Resources/config/admin.yml');
|
||||
|
||||
$container->loadFromExtension('framework', [
|
||||
'secret' => $this->secret,
|
||||
]);
|
||||
|
||||
if (\Tools::version_compare($this->psVersion, '1.7.4', '>=')) {
|
||||
$loader->load(sprintf('%s/services/sf34.yml', $configDir));
|
||||
} else {
|
||||
$loader->load(sprintf('%s/services/sf28.yml', $configDir));
|
||||
$loader->load(__DIR__ . '/Resources/config/admin28.yml');
|
||||
|
||||
$container->addCompilerPass(new ProvideServiceLocatorFactoriesPass('inpost.izi.service_locator'));
|
||||
AnalyzeServiceReferencesPass::decorateRemovingPasses($container, 'inpost.izi.service_locator');
|
||||
$container->addCompilerPass(new TaggedIteratorsCollectorPass());
|
||||
}
|
||||
}
|
||||
|
||||
protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container, $class, $baseClass): void
|
||||
{
|
||||
if (\Tools::version_compare($this->psVersion, '1.7.4', '>=')) {
|
||||
parent::dumpContainer(...func_get_args());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$dumper = new PhpDumper($container);
|
||||
|
||||
$content = $dumper->dump([
|
||||
'class' => $class,
|
||||
'base_class' => $baseClass,
|
||||
'file' => $cache->getPath(),
|
||||
'debug' => $this->debug,
|
||||
]);
|
||||
|
||||
$cache->write($content, $container->getResources());
|
||||
}
|
||||
|
||||
private function getPrestaShopBundle(): BundleInterface
|
||||
{
|
||||
return $this->prestaShopBundle ?? ($this->prestaShopBundle = new PrestaShopBundle());
|
||||
}
|
||||
|
||||
private function getConfigIndexRoute(): Route
|
||||
{
|
||||
return (new Route('/'))
|
||||
->setMethods(['GET', 'POST'])
|
||||
->setDefault('_controller', 'izi\prestashop\Controller\Admin\ConfigurationController:generalConfig');
|
||||
}
|
||||
|
||||
private function getConfigDir(): string
|
||||
{
|
||||
return __DIR__ . '/../config';
|
||||
}
|
||||
}
|
||||
61
modules/inpostizi/src/Analytics/BasketAnalytics.php
Normal file
61
modules/inpostizi/src/Analytics/BasketAnalytics.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Analytics;
|
||||
|
||||
class BasketAnalytics implements BasketAnalyticsInterface
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $cartId;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $gclid;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $fbclid;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $client_id;
|
||||
|
||||
public function __construct(int $cartId, ?string $gclid, ?string $fbclid, ?string $client_id)
|
||||
{
|
||||
$this->cartId = $cartId;
|
||||
$this->gclid = $gclid;
|
||||
$this->fbclid = $fbclid;
|
||||
$this->client_id = $client_id;
|
||||
}
|
||||
|
||||
public function getCartId(): int
|
||||
{
|
||||
return $this->cartId;
|
||||
}
|
||||
|
||||
public function getGclid(): ?string
|
||||
{
|
||||
return $this->gclid;
|
||||
}
|
||||
|
||||
public function getFbclid(): ?string
|
||||
{
|
||||
return $this->fbclid;
|
||||
}
|
||||
|
||||
public function getClientId(): ?string
|
||||
{
|
||||
return $this->client_id;
|
||||
}
|
||||
|
||||
public function isEmpty(): bool
|
||||
{
|
||||
return null === $this->gclid && null === $this->fbclid && null === $this->client_id;
|
||||
}
|
||||
}
|
||||
16
modules/inpostizi/src/Analytics/BasketAnalyticsInterface.php
Normal file
16
modules/inpostizi/src/Analytics/BasketAnalyticsInterface.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Analytics;
|
||||
|
||||
interface BasketAnalyticsInterface
|
||||
{
|
||||
public function getGclid(): ?string;
|
||||
|
||||
public function getFbclid(): ?string;
|
||||
|
||||
public function getClientId(): ?string;
|
||||
|
||||
public function isEmpty(): bool;
|
||||
}
|
||||
50
modules/inpostizi/src/Analytics/BasketAnalyticsParams.php
Normal file
50
modules/inpostizi/src/Analytics/BasketAnalyticsParams.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Analytics;
|
||||
|
||||
class BasketAnalyticsParams implements BasketAnalyticsInterface
|
||||
{
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $gclid;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $fbclid;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $client_id;
|
||||
|
||||
public function __construct(?string $gclid, ?string $fbclid, ?string $client_id)
|
||||
{
|
||||
$this->gclid = $gclid;
|
||||
$this->fbclid = $fbclid;
|
||||
$this->client_id = $client_id;
|
||||
}
|
||||
|
||||
public function getGclid(): ?string
|
||||
{
|
||||
return $this->gclid;
|
||||
}
|
||||
|
||||
public function getFbclid(): ?string
|
||||
{
|
||||
return $this->fbclid;
|
||||
}
|
||||
|
||||
public function getClientId(): ?string
|
||||
{
|
||||
return $this->client_id;
|
||||
}
|
||||
|
||||
public function isEmpty(): bool
|
||||
{
|
||||
return null === $this->gclid && null === $this->fbclid && null === $this->client_id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Analytics;
|
||||
|
||||
use izi\prestashop\Database\Connection;
|
||||
|
||||
class BasketAnalyticsRepository implements BasketAnalyticsRepositoryInterface
|
||||
{
|
||||
public const TABLE_NAME = 'inpostizi_basket_analytics';
|
||||
|
||||
/**
|
||||
* @var Connection
|
||||
*/
|
||||
private $connection;
|
||||
|
||||
public function __construct(Connection $connection)
|
||||
{
|
||||
$this->connection = $connection;
|
||||
}
|
||||
|
||||
public function add(BasketAnalytics $basketAnalytics): void
|
||||
{
|
||||
$this->connection->insert(self::TABLE_NAME, [
|
||||
'cart_id' => $basketAnalytics->getCartId(),
|
||||
'gclid' => $basketAnalytics->getGclid(),
|
||||
'fbclid' => $basketAnalytics->getFbclid(),
|
||||
'client_id' => $basketAnalytics->getClientId(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function find(int $id): ?BasketAnalyticsInterface
|
||||
{
|
||||
$qb = $this->createQueryBuilder()->where('cart_id = ' . $id);
|
||||
|
||||
return $this->getOneOrNullResult($qb);
|
||||
}
|
||||
|
||||
public function remove(int $id): void
|
||||
{
|
||||
$this->connection->delete(self::TABLE_NAME, [
|
||||
'cart_id' => $id,
|
||||
]);
|
||||
}
|
||||
|
||||
public function save(BasketAnalytics $basketAnalytics): void
|
||||
{
|
||||
$exists = $this->find($basketAnalytics->getCartId());
|
||||
|
||||
if (null === $exists) {
|
||||
$this->add($basketAnalytics);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->connection->update(self::TABLE_NAME, [
|
||||
'gclid' => $basketAnalytics->getGclid(),
|
||||
'fbclid' => $basketAnalytics->getFbclid(),
|
||||
'client_id' => $basketAnalytics->getClientId(),
|
||||
], [
|
||||
'cart_id' => $basketAnalytics->getCartId(),
|
||||
]);
|
||||
}
|
||||
|
||||
protected function createQueryBuilder(): \DbQuery
|
||||
{
|
||||
return (new \DbQuery())->from(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
protected function getOneOrNullResult(\DbQuery $qb): ?BasketAnalytics
|
||||
{
|
||||
if (false === $row = $this->connection->fetchAssociative((string) $qb)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->hydrate($row);
|
||||
}
|
||||
|
||||
protected function hydrate(array $row): BasketAnalytics
|
||||
{
|
||||
return new BasketAnalytics(
|
||||
(int)$row['cart_id'],
|
||||
$row['gclid'],
|
||||
$row['fbclid'],
|
||||
$row['client_id']
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Analytics;
|
||||
|
||||
interface BasketAnalyticsRepositoryInterface
|
||||
{
|
||||
public function find(int $id): ?BasketAnalyticsInterface;
|
||||
|
||||
public function save(BasketAnalytics $basketAnalytics): void;
|
||||
|
||||
public function remove(int $id): void;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Analytics\Command;
|
||||
|
||||
use izi\prestashop\Analytics\BasketAnalyticsInterface;
|
||||
|
||||
/**
|
||||
* @see UpdateCartAnalyticsHandler
|
||||
*/
|
||||
final class UpdateCartAnalyticsCommand
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $cartId;
|
||||
|
||||
/**
|
||||
* @var BasketAnalyticsInterface
|
||||
*/
|
||||
private $basketAnalytics;
|
||||
|
||||
public function __construct(int $cartId, BasketAnalyticsInterface $basketAnalytics)
|
||||
{
|
||||
$this->cartId = $cartId;
|
||||
$this->basketAnalytics = $basketAnalytics;
|
||||
}
|
||||
|
||||
public function getCartId(): int
|
||||
{
|
||||
return $this->cartId;
|
||||
}
|
||||
|
||||
public function getBasketAnalytics(): BasketAnalyticsInterface
|
||||
{
|
||||
return $this->basketAnalytics;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Analytics\Cookie;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
interface CookieEraserInterface
|
||||
{
|
||||
public function erase(Request $request): void;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Analytics\Cookie;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
interface CookieExtractorInterface
|
||||
{
|
||||
public function extract(Request $request): ?string;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Analytics\Cookie;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
interface CookiePersisterInterface
|
||||
{
|
||||
public function persist(Request $request): void;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Analytics\Cookie\Executor;
|
||||
|
||||
use izi\prestashop\Analytics\Cookie\CookieEraserInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class CookieEraseExecutor implements CookieEraserInterface
|
||||
{
|
||||
/**
|
||||
* @var iterable<CookieEraserInterface>
|
||||
*/
|
||||
private $erasers;
|
||||
|
||||
/**
|
||||
* @param iterable<CookieEraserInterface> $erasers
|
||||
*/
|
||||
public function __construct(iterable $erasers)
|
||||
{
|
||||
$this->erasers = $erasers;
|
||||
}
|
||||
|
||||
public function erase(Request $request): void
|
||||
{
|
||||
foreach ($this->erasers as $eraser) {
|
||||
$eraser->erase($request);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Analytics\Cookie\Executor;
|
||||
|
||||
use izi\prestashop\Analytics\Cookie\CookiePersisterInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class CookiePersisterExecutor implements CookiePersisterInterface
|
||||
{
|
||||
/**
|
||||
* @var iterable<CookiePersisterInterface>
|
||||
*/
|
||||
private $persisters;
|
||||
|
||||
/**
|
||||
* @param iterable<CookiePersisterInterface> $persisters
|
||||
*/
|
||||
public function __construct(iterable $persisters)
|
||||
{
|
||||
$this->persisters = $persisters;
|
||||
}
|
||||
|
||||
public function persist(Request $request): void
|
||||
{
|
||||
foreach ($this->persisters as $persister) {
|
||||
$persister->persist($request);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Analytics\Cookie;
|
||||
|
||||
use izi\prestashop\Analytics\Cookie\Factory\CookieFactoryInterface;
|
||||
use izi\prestashop\Analytics\Cookie\Repository\CookieRepositoryInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
final class FacebookClickIdCookie implements CookieExtractorInterface, CookiePersisterInterface, CookieEraserInterface
|
||||
{
|
||||
private const COOKIE_NAME = 'izi_fbclid';
|
||||
private const PARAMETER = 'fbclid';
|
||||
private const COOKIE_EXPIRE_TIME = 3600;
|
||||
|
||||
/**
|
||||
* @var CookieFactoryInterface
|
||||
*/
|
||||
private $cookieFactory;
|
||||
|
||||
/**
|
||||
* @var CookieRepositoryInterface
|
||||
*/
|
||||
private $cookieRepository;
|
||||
|
||||
public function __construct(
|
||||
CookieFactoryInterface $cookieFactory,
|
||||
CookieRepositoryInterface $cookieRepository
|
||||
) {
|
||||
$this->cookieFactory = $cookieFactory;
|
||||
$this->cookieRepository = $cookieRepository;
|
||||
}
|
||||
|
||||
public function extract(Request $request): ?string
|
||||
{
|
||||
if ($request->cookies->has(self::COOKIE_NAME)) {
|
||||
return $request->cookies->get(self::COOKIE_NAME);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function persist(Request $request): void
|
||||
{
|
||||
$parameter = $request->query->get(self::PARAMETER);
|
||||
|
||||
if (null === $parameter) {
|
||||
return;
|
||||
}
|
||||
|
||||
$cookie = $this->cookieFactory->create(self::COOKIE_NAME, $parameter, time() + self::COOKIE_EXPIRE_TIME);
|
||||
|
||||
$this->cookieRepository->persist($cookie);
|
||||
}
|
||||
|
||||
public function erase(Request $request): void
|
||||
{
|
||||
if ($request->cookies->has(self::COOKIE_NAME)) {
|
||||
$cookie = $this->cookieFactory->create(self::COOKIE_NAME, '', -1);
|
||||
|
||||
unset($_COOKIE[self::COOKIE_NAME]);
|
||||
$this->cookieRepository->persist($cookie);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Analytics\Cookie\Factory;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Cookie;
|
||||
|
||||
final class CookieFactory implements CookieFactoryInterface
|
||||
{
|
||||
public function create(
|
||||
$name,
|
||||
$value,
|
||||
int $expire = 0,
|
||||
string $path = '/',
|
||||
string $domain = '',
|
||||
bool $secure = false,
|
||||
bool $httpOnly = true
|
||||
): Cookie {
|
||||
return new Cookie(
|
||||
$name,
|
||||
$value,
|
||||
$expire,
|
||||
$path,
|
||||
$domain,
|
||||
$secure,
|
||||
$httpOnly
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Analytics\Cookie\Factory;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Cookie;
|
||||
|
||||
interface CookieFactoryInterface
|
||||
{
|
||||
public function create(
|
||||
$name,
|
||||
$value,
|
||||
int $expire = 0,
|
||||
string $path = '/',
|
||||
string $domain = '',
|
||||
bool $secure = false,
|
||||
bool $httpOnly = true
|
||||
): Cookie;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Analytics\Cookie;
|
||||
|
||||
use izi\prestashop\Analytics\Cookie\Factory\CookieFactoryInterface;
|
||||
use izi\prestashop\Analytics\Cookie\Repository\CookieRepositoryInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
final class GoogleClickIdCookie implements CookieExtractorInterface, CookiePersisterInterface, CookieEraserInterface
|
||||
{
|
||||
private const COOKIE_NAME = 'izi_gclid';
|
||||
private const PARAMETER = 'gclid';
|
||||
private const COOKIE_EXPIRE_TIME = 3600;
|
||||
|
||||
/**
|
||||
* @var CookieFactoryInterface
|
||||
*/
|
||||
private $cookieFactory;
|
||||
|
||||
/**
|
||||
* @var CookieRepositoryInterface
|
||||
*/
|
||||
private $cookieRepository;
|
||||
|
||||
public function __construct(
|
||||
CookieFactoryInterface $cookieFactory,
|
||||
CookieRepositoryInterface $cookieRepository
|
||||
) {
|
||||
$this->cookieFactory = $cookieFactory;
|
||||
$this->cookieRepository = $cookieRepository;
|
||||
}
|
||||
|
||||
public function extract(Request $request): ?string
|
||||
{
|
||||
if ($request->cookies->has(self::COOKIE_NAME)) {
|
||||
return $request->cookies->get(self::COOKIE_NAME);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function persist(Request $request): void
|
||||
{
|
||||
$parameter = $request->query->get(self::PARAMETER);
|
||||
|
||||
if (null === $parameter) {
|
||||
return;
|
||||
}
|
||||
|
||||
$cookie = $this->cookieFactory->create(self::COOKIE_NAME, $parameter, time() + self::COOKIE_EXPIRE_TIME);
|
||||
|
||||
$this->cookieRepository->persist($cookie);
|
||||
}
|
||||
|
||||
public function erase(Request $request): void
|
||||
{
|
||||
if ($request->cookies->has(self::COOKIE_NAME)) {
|
||||
$cookie = $this->cookieFactory->create(self::COOKIE_NAME, '', -1);
|
||||
|
||||
unset($_COOKIE[self::COOKIE_NAME]);
|
||||
$this->cookieRepository->persist($cookie);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Analytics\Cookie;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
final class GoogleClientIdCookie implements CookieExtractorInterface
|
||||
{
|
||||
private const COOKIE_NAME = '_ga';
|
||||
|
||||
public function extract(Request $request): ?string
|
||||
{
|
||||
if ($request->cookies->has(self::COOKIE_NAME)) {
|
||||
$gaCookie = $request->cookies->get(self::COOKIE_NAME);
|
||||
$parts = explode('.', $gaCookie);
|
||||
|
||||
if (count($parts) >= 3) {
|
||||
return implode('.', array_slice($parts, 2));
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Analytics\Cookie\Repository;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Cookie;
|
||||
|
||||
final class CookieRepository implements CookieRepositoryInterface
|
||||
{
|
||||
public function persist(Cookie $cookie): void
|
||||
{
|
||||
setcookie(
|
||||
$cookie->getName(),
|
||||
$cookie->getValue(),
|
||||
$cookie->getExpiresTime(),
|
||||
$cookie->getPath(),
|
||||
$cookie->getDomain() ?? '',
|
||||
$cookie->isSecure(),
|
||||
$cookie->isHttpOnly()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Analytics\Cookie\Repository;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Cookie;
|
||||
|
||||
interface CookieRepositoryInterface
|
||||
{
|
||||
public function persist(Cookie $cookie): void;
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Analytics\EventListener;
|
||||
|
||||
use izi\prestashop\Analytics\Command\UpdateCartAnalyticsCommand;
|
||||
use izi\prestashop\Analytics\Cookie\CookieEraserInterface;
|
||||
use izi\prestashop\Analytics\Factory\BasketAnalyticsFactoryInterface;
|
||||
use izi\prestashop\CommandBusInterface;
|
||||
use izi\prestashop\Configuration\GeneralConfigurationInterface;
|
||||
use izi\prestashop\Event\CartUpdatedEvent;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
|
||||
final class UpdateBasketAnalyticsListener implements EventSubscriberInterface
|
||||
{
|
||||
/**
|
||||
* @var CommandBusInterface
|
||||
*/
|
||||
private $commandBus;
|
||||
|
||||
/**
|
||||
* @var RequestStack
|
||||
*/
|
||||
private $requestStack;
|
||||
|
||||
/**
|
||||
* @var BasketAnalyticsFactoryInterface
|
||||
*/
|
||||
private $basketAnalyticsFactory;
|
||||
|
||||
/**
|
||||
* @var CookieEraserInterface
|
||||
*/
|
||||
private $cookieEraser;
|
||||
|
||||
/**
|
||||
* @var GeneralConfigurationInterface
|
||||
*/
|
||||
private $generalConfiguration;
|
||||
|
||||
public function __construct(
|
||||
CommandBusInterface $commandBus,
|
||||
RequestStack $requestStack,
|
||||
BasketAnalyticsFactoryInterface $basketAnalyticsFactory,
|
||||
CookieEraserInterface $cookieEraser,
|
||||
GeneralConfigurationInterface $generalConfiguration
|
||||
) {
|
||||
$this->commandBus = $commandBus;
|
||||
$this->requestStack = $requestStack;
|
||||
$this->basketAnalyticsFactory = $basketAnalyticsFactory;
|
||||
$this->cookieEraser = $cookieEraser;
|
||||
$this->generalConfiguration = $generalConfiguration;
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return [
|
||||
CartUpdatedEvent::class => 'onCartUpdated',
|
||||
];
|
||||
}
|
||||
|
||||
public function onCartUpdated(CartUpdatedEvent $event): void
|
||||
{
|
||||
$request = $this->requestStack->getCurrentRequest();
|
||||
|
||||
if (null === $request || !$this->generalConfiguration->isSendAnalyticsData()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$basketAnalytics = $this->basketAnalyticsFactory->createFromRequest($request);
|
||||
|
||||
if ($basketAnalytics->isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->commandBus->handle(new UpdateCartAnalyticsCommand((int) $event->getCart()->id, $basketAnalytics));
|
||||
$this->cookieEraser->erase($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Analytics\Factory;
|
||||
|
||||
use izi\prestashop\Analytics\BasketAnalyticsInterface;
|
||||
use izi\prestashop\Analytics\BasketAnalyticsParams;
|
||||
use izi\prestashop\Analytics\Cookie\CookieExtractorInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
final class BasketAnalyticsFactory implements BasketAnalyticsFactoryInterface
|
||||
{
|
||||
/**
|
||||
* @var CookieExtractorInterface
|
||||
*/
|
||||
private $gclidExtractor;
|
||||
|
||||
/**
|
||||
* @var CookieExtractorInterface
|
||||
*/
|
||||
private $fbclidExtractor;
|
||||
|
||||
/**
|
||||
* @var CookieExtractorInterface
|
||||
*/
|
||||
private $clientIdExtractor;
|
||||
|
||||
public function __construct(
|
||||
CookieExtractorInterface $gclidExtractor,
|
||||
CookieExtractorInterface $fbclidExtractor,
|
||||
CookieExtractorInterface $clientIdExtractor
|
||||
) {
|
||||
$this->gclidExtractor = $gclidExtractor;
|
||||
$this->fbclidExtractor = $fbclidExtractor;
|
||||
$this->clientIdExtractor = $clientIdExtractor;
|
||||
}
|
||||
|
||||
public function createFromRequest(Request $request): BasketAnalyticsInterface
|
||||
{
|
||||
$gclid = $this->gclidExtractor->extract($request);
|
||||
$fbclid = $this->fbclidExtractor->extract($request);
|
||||
$clientId = $this->clientIdExtractor->extract($request);
|
||||
|
||||
return new BasketAnalyticsParams($gclid, $fbclid, $clientId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Analytics\Factory;
|
||||
|
||||
use izi\prestashop\Analytics\BasketAnalyticsInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
interface BasketAnalyticsFactoryInterface
|
||||
{
|
||||
public function createFromRequest(Request $request): BasketAnalyticsInterface;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Analytics\Handler;
|
||||
|
||||
use izi\prestashop\Analytics\BasketAnalytics;
|
||||
use izi\prestashop\Analytics\BasketAnalyticsRepositoryInterface;
|
||||
use izi\prestashop\Analytics\Command\UpdateCartAnalyticsCommand;
|
||||
|
||||
final class UpdateCartAnalyticsHandler implements UpdateCartAnalyticsHandlerInterface
|
||||
{
|
||||
/**
|
||||
* @var BasketAnalyticsRepositoryInterface
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
public function __construct(BasketAnalyticsRepositoryInterface $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
private function getNewFieldValue(?string $oldKey, ?string $newKey): ?string
|
||||
{
|
||||
if (null === $oldKey || $oldKey !== $newKey) {
|
||||
return $newKey;
|
||||
}
|
||||
|
||||
return $oldKey;
|
||||
}
|
||||
|
||||
public function __invoke(UpdateCartAnalyticsCommand $command)
|
||||
{
|
||||
$currentBasketRepository = $this->repository->find($command->getCartId());
|
||||
|
||||
if (null === $currentBasketRepository) {
|
||||
$basketAnalytics = new BasketAnalytics(
|
||||
$command->getCartId(),
|
||||
$command->getBasketAnalytics()->getGclid(),
|
||||
$command->getBasketAnalytics()->getFbclid(),
|
||||
$command->getBasketAnalytics()->getClientId()
|
||||
);
|
||||
|
||||
$this->repository->save($basketAnalytics);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$basketAnalytics = new BasketAnalytics(
|
||||
$command->getCartId(),
|
||||
$this->getNewFieldValue($currentBasketRepository->getGclid(), $command->getBasketAnalytics()->getGclid()),
|
||||
$this->getNewFieldValue($currentBasketRepository->getFbclid(), $command->getBasketAnalytics()->getFbclid()),
|
||||
$this->getNewFieldValue($currentBasketRepository->getClientId(), $command->getBasketAnalytics()->getClientId())
|
||||
);
|
||||
|
||||
$this->repository->save($basketAnalytics);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Analytics\Handler;
|
||||
|
||||
use izi\prestashop\Analytics\Command\UpdateCartAnalyticsCommand;
|
||||
|
||||
interface UpdateCartAnalyticsHandlerInterface
|
||||
{
|
||||
public function __invoke(UpdateCartAnalyticsCommand $command);
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp;
|
||||
|
||||
use izi\prestashop\Http\Client\Factory\ClientFactoryInterface;
|
||||
use izi\prestashop\Http\Client\Factory\GuzzleClientFactory;
|
||||
use izi\prestashop\OAuth2\Authentication\ClientCredentialsInterface;
|
||||
use izi\prestashop\OAuth2\Authentication\ClientSecretPost;
|
||||
use izi\prestashop\OAuth2\AuthorizationProvider;
|
||||
use izi\prestashop\OAuth2\AuthorizationProviderFactoryInterface;
|
||||
use izi\prestashop\OAuth2\AuthorizationProviderInterface;
|
||||
use izi\prestashop\OAuth2\AuthorizationServerClient;
|
||||
use izi\prestashop\OAuth2\AuthorizationServerClientInterface;
|
||||
use izi\prestashop\OAuth2\Grant\ClientCredentialsGrant;
|
||||
use izi\prestashop\OAuth2\Token\AccessTokenRepositoryInterface;
|
||||
use izi\prestashop\OAuth2\UriCollectionInterface;
|
||||
use Psr\Http\Message\RequestFactoryInterface;
|
||||
use Psr\Http\Message\StreamFactoryInterface;
|
||||
|
||||
final class AuthorizationProviderFactory implements AuthorizationProviderFactoryInterface
|
||||
{
|
||||
/**
|
||||
* @var RequestFactoryInterface
|
||||
*/
|
||||
private $requestFactory;
|
||||
|
||||
/**
|
||||
* @var StreamFactoryInterface
|
||||
*/
|
||||
private $streamFactory;
|
||||
|
||||
/**
|
||||
* @var ClientFactoryInterface
|
||||
*/
|
||||
private $clientFactory;
|
||||
|
||||
public function __construct(RequestFactoryInterface $requestFactory, StreamFactoryInterface $streamFactory, ?ClientFactoryInterface $clientFactory = null)
|
||||
{
|
||||
$this->requestFactory = $requestFactory;
|
||||
$this->streamFactory = $streamFactory;
|
||||
$this->clientFactory = $clientFactory ?? new GuzzleClientFactory();
|
||||
}
|
||||
|
||||
public function create(UriCollectionInterface $uriCollection, ClientCredentialsInterface $credentials, ?AccessTokenRepositoryInterface $tokenRepository = null): AuthorizationProviderInterface
|
||||
{
|
||||
$authSeverClient = $this->createAuthServerClient($uriCollection);
|
||||
|
||||
return new AuthorizationProvider(
|
||||
$authSeverClient,
|
||||
new ClientCredentialsGrant(),
|
||||
$credentials,
|
||||
$tokenRepository
|
||||
);
|
||||
}
|
||||
|
||||
private function createAuthServerClient(UriCollectionInterface $uriCollection): AuthorizationServerClientInterface
|
||||
{
|
||||
$httpClient = $this->clientFactory->create();
|
||||
|
||||
return new AuthorizationServerClient(
|
||||
$httpClient,
|
||||
$this->requestFactory,
|
||||
$this->streamFactory,
|
||||
$uriCollection,
|
||||
new ClientSecretPost()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Basket;
|
||||
|
||||
use izi\prestashop\BasketApp\Basket\Request\Basket;
|
||||
use izi\prestashop\BasketApp\Basket\Response\BasketBindingKeyResponse;
|
||||
use izi\prestashop\BasketApp\Basket\Response\BasketBindingResponse;
|
||||
use izi\prestashop\BasketApp\Basket\Response\UpdateBasketResponse;
|
||||
use izi\prestashop\BasketApp\Exception\BasketExpiredException;
|
||||
use izi\prestashop\BasketApp\Exception\BasketNotBoundException;
|
||||
use izi\prestashop\BasketApp\Exception\BasketNotFoundException;
|
||||
|
||||
interface BasketsApiClientInterface
|
||||
{
|
||||
/**
|
||||
* @throws BasketNotFoundException
|
||||
* @throws BasketExpiredException
|
||||
* @throws BasketNotBoundException
|
||||
*/
|
||||
public function deleteBasketBinding(string $basketId, bool $orderCompleted = false): void;
|
||||
|
||||
/**
|
||||
* @throws BasketExpiredException
|
||||
*/
|
||||
public function getBasketBinding(string $basketId, ?string $browserId = null): BasketBindingResponse;
|
||||
|
||||
public function initializeBasketBinding(string $basketId): BasketBindingKeyResponse;
|
||||
|
||||
/**
|
||||
* @throws BasketNotFoundException
|
||||
* @throws BasketExpiredException
|
||||
*/
|
||||
public function updateBasket(string $basketId, Basket $basket): UpdateBasketResponse;
|
||||
}
|
||||
130
modules/inpostizi/src/BasketApp/Basket/Request/Basket.php
Normal file
130
modules/inpostizi/src/BasketApp/Basket/Request/Basket.php
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Basket\Request;
|
||||
|
||||
use izi\prestashop\Common\Basket\AvailablePromotion;
|
||||
use izi\prestashop\Common\Basket\Consent;
|
||||
use izi\prestashop\Common\Basket\DeliveryOption;
|
||||
use izi\prestashop\Common\Basket\Product;
|
||||
use izi\prestashop\Common\Basket\Summary;
|
||||
use izi\prestashop\Common\PromoCode;
|
||||
|
||||
final class Basket implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* @var Summary
|
||||
*/
|
||||
private $summary;
|
||||
|
||||
/**
|
||||
* @var DeliveryOption[]
|
||||
*/
|
||||
private $delivery;
|
||||
|
||||
/**
|
||||
* @var PromoCode[]
|
||||
*/
|
||||
private $promo_codes;
|
||||
|
||||
/**
|
||||
* @var Product[]
|
||||
*/
|
||||
private $products;
|
||||
|
||||
/**
|
||||
* @var Product[]
|
||||
*/
|
||||
private $related_products;
|
||||
|
||||
/**
|
||||
* @var Consent[]
|
||||
*/
|
||||
private $consents;
|
||||
|
||||
/**
|
||||
* @var AvailablePromotion[]
|
||||
*/
|
||||
private $promotions_available;
|
||||
|
||||
/**
|
||||
* @param DeliveryOption[] $delivery
|
||||
* @param PromoCode[] $promo_codes
|
||||
* @param Product[] $products
|
||||
* @param Product[] $related_products
|
||||
* @param Consent[] $consents
|
||||
* @param AvailablePromotion[] $promotions_available
|
||||
*/
|
||||
public function __construct(Summary $summary, array $delivery, array $products, array $consents, array $promo_codes = [], array $related_products = [], array $promotions_available = [])
|
||||
{
|
||||
$this->summary = $summary;
|
||||
$this->delivery = $delivery;
|
||||
$this->promo_codes = $promo_codes;
|
||||
$this->products = $products;
|
||||
$this->related_products = $related_products;
|
||||
$this->consents = $consents;
|
||||
$this->promotions_available = $promotions_available;
|
||||
}
|
||||
|
||||
public function getSummary(): Summary
|
||||
{
|
||||
return $this->summary;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DeliveryOption[]
|
||||
*/
|
||||
public function getDelivery(): array
|
||||
{
|
||||
return $this->delivery;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PromoCode[]
|
||||
*/
|
||||
public function getPromoCodes(): array
|
||||
{
|
||||
return $this->promo_codes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Product[]
|
||||
*/
|
||||
public function getProducts(): array
|
||||
{
|
||||
return $this->products;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Product[]
|
||||
*/
|
||||
public function getRelatedProducts(): array
|
||||
{
|
||||
return $this->related_products;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Consent[]
|
||||
*/
|
||||
public function getConsents(): array
|
||||
{
|
||||
return $this->consents;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AvailablePromotion[]
|
||||
*/
|
||||
public function getPromotionsAvailable(): array
|
||||
{
|
||||
return $this->promotions_available;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return get_object_vars($this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Basket\Response;
|
||||
|
||||
final class BasketBindingKeyResponse implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $basket_binding_api_key;
|
||||
|
||||
public function __construct(string $basket_binding_api_key)
|
||||
{
|
||||
$this->basket_binding_api_key = $basket_binding_api_key;
|
||||
}
|
||||
|
||||
public function getBindingKey(): string
|
||||
{
|
||||
return $this->basket_binding_api_key;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return get_object_vars($this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Basket\Response;
|
||||
|
||||
final class BasketBindingResponse implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $basket_linked;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $browser_trusted;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $inpost_basket_id;
|
||||
|
||||
/**
|
||||
* @var ClientDetails|null
|
||||
*/
|
||||
private $client_details;
|
||||
|
||||
public function __construct(bool $basket_linked, bool $browser_trusted, ?string $inpost_basket_id = null, ?ClientDetails $client_details = null)
|
||||
{
|
||||
$this->basket_linked = $basket_linked;
|
||||
$this->browser_trusted = $browser_trusted;
|
||||
$this->inpost_basket_id = $inpost_basket_id;
|
||||
$this->client_details = $client_details;
|
||||
}
|
||||
|
||||
public function isBasketLinked(): bool
|
||||
{
|
||||
return $this->basket_linked;
|
||||
}
|
||||
|
||||
public function isBrowserTrusted(): bool
|
||||
{
|
||||
return $this->browser_trusted;
|
||||
}
|
||||
|
||||
public function getInPostBasketId(): ?string
|
||||
{
|
||||
return $this->inpost_basket_id;
|
||||
}
|
||||
|
||||
public function getClientDetails(): ?ClientDetails
|
||||
{
|
||||
return $this->client_details;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return get_object_vars($this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Basket\Response;
|
||||
|
||||
use izi\prestashop\Common\PhoneNumber;
|
||||
|
||||
final class ClientDetails implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* @var PhoneNumber
|
||||
*/
|
||||
private $phone_number;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $masked_phone_number;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $surname;
|
||||
|
||||
public function __construct(PhoneNumber $phone_number, string $masked_phone_number, string $name, string $surname)
|
||||
{
|
||||
$this->phone_number = $phone_number;
|
||||
$this->masked_phone_number = $masked_phone_number;
|
||||
$this->name = $name;
|
||||
$this->surname = $surname;
|
||||
}
|
||||
|
||||
public function getPhoneNumber(): PhoneNumber
|
||||
{
|
||||
return $this->phone_number;
|
||||
}
|
||||
|
||||
public function getMaskedPhoneNumber(): string
|
||||
{
|
||||
return $this->masked_phone_number;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getSurname(): string
|
||||
{
|
||||
return $this->surname;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return get_object_vars($this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Basket\Response;
|
||||
|
||||
final class UpdateBasketResponse implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $inpost_basket_id;
|
||||
|
||||
public function __construct(string $inpost_basket_id)
|
||||
{
|
||||
$this->inpost_basket_id = $inpost_basket_id;
|
||||
}
|
||||
|
||||
public function getInPostBasketId(): string
|
||||
{
|
||||
return $this->inpost_basket_id;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return get_object_vars($this);
|
||||
}
|
||||
}
|
||||
298
modules/inpostizi/src/BasketApp/BasketAppClient.php
Normal file
298
modules/inpostizi/src/BasketApp/BasketAppClient.php
Normal file
@@ -0,0 +1,298 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp;
|
||||
|
||||
use izi\prestashop\BasketApp\Basket\Request\Basket;
|
||||
use izi\prestashop\BasketApp\Basket\Response\BasketBindingKeyResponse;
|
||||
use izi\prestashop\BasketApp\Basket\Response\BasketBindingResponse;
|
||||
use izi\prestashop\BasketApp\Basket\Response\UpdateBasketResponse;
|
||||
use izi\prestashop\BasketApp\Exception\BasketAppException;
|
||||
use izi\prestashop\BasketApp\Order\Request\OrderEvent;
|
||||
use izi\prestashop\BasketApp\Payment\Response\AvailablePaymentOptions;
|
||||
use izi\prestashop\BasketApp\Product\ProductsApiClientInterface;
|
||||
use izi\prestashop\BasketApp\Product\Request\CreateProductsRequest;
|
||||
use izi\prestashop\BasketApp\Product\Response\CreateProductsResponse;
|
||||
use izi\prestashop\BasketApp\Product\Response\Product as ResponseProduct;
|
||||
use izi\prestashop\BasketApp\Signature\Response\SigningKey;
|
||||
use izi\prestashop\BasketApp\Signature\Response\SigningKeys;
|
||||
use izi\prestashop\Common\Error\Error;
|
||||
use izi\prestashop\Common\HotProduct\Product;
|
||||
use izi\prestashop\Environment\ProductionEnvironment;
|
||||
use izi\prestashop\Http\Exception\ClientException;
|
||||
use izi\prestashop\Http\Exception\RedirectionException;
|
||||
use izi\prestashop\Http\Exception\ServerException;
|
||||
use izi\prestashop\Http\Util\UriResolver;
|
||||
use izi\prestashop\Serializer\Normalizer\BasketAppPaginationPageDenormalizer;
|
||||
use Psr\Http\Client\ClientInterface;
|
||||
use Psr\Http\Message\RequestFactoryInterface;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\StreamFactoryInterface;
|
||||
use Symfony\Component\Serializer\Exception\ExceptionInterface;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
|
||||
final class BasketAppClient implements BasketAppClientInterface, ProductsApiClientInterface
|
||||
{
|
||||
/**
|
||||
* @var ClientInterface
|
||||
*/
|
||||
private $client;
|
||||
|
||||
/**
|
||||
* @var RequestFactoryInterface
|
||||
*/
|
||||
private $requestFactory;
|
||||
|
||||
/**
|
||||
* @var StreamFactoryInterface
|
||||
*/
|
||||
private $streamFactory;
|
||||
|
||||
/**
|
||||
* @var SerializerInterface
|
||||
*/
|
||||
private $serializer;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $baseUri;
|
||||
|
||||
public function __construct(ClientInterface $client, RequestFactoryInterface $requestFactory, StreamFactoryInterface $streamFactory, SerializerInterface $serializer, ?string $baseUri = null)
|
||||
{
|
||||
$this->client = $client;
|
||||
$this->requestFactory = $requestFactory;
|
||||
$this->streamFactory = $streamFactory;
|
||||
$this->serializer = $serializer;
|
||||
$this->baseUri = $baseUri ?? (new ProductionEnvironment())->getBasketAppApiUri();
|
||||
}
|
||||
|
||||
public function updateBasket(string $basketId, Basket $basket): UpdateBasketResponse
|
||||
{
|
||||
$request = $this->createRequest('PUT', sprintf('/v2/izi/basket/%s', $basketId), $basket);
|
||||
$response = $this->sendRequest($request);
|
||||
|
||||
return $this->deserialize($response, UpdateBasketResponse::class);
|
||||
}
|
||||
|
||||
public function initializeBasketBinding(string $basketId): BasketBindingKeyResponse
|
||||
{
|
||||
$request = $this->createRequest('PUT', sprintf('/v2/izi/basket/%s/binding', $basketId));
|
||||
$response = $this->sendRequest($request);
|
||||
|
||||
return $this->deserialize($response, BasketBindingKeyResponse::class);
|
||||
}
|
||||
|
||||
public function deleteBasketBinding(string $basketId, bool $orderCompleted = false): void
|
||||
{
|
||||
$uri = sprintf('/v1/izi/basket/%s/binding', $basketId);
|
||||
if ($orderCompleted) {
|
||||
$uri .= '?' . self::buildQuery(['if_basket_realized' => (int) $orderCompleted]);
|
||||
}
|
||||
|
||||
$request = $this->createRequest('DELETE', $uri);
|
||||
$this->sendRequest($request, 204);
|
||||
}
|
||||
|
||||
public function getBasketBinding(string $basketId, ?string $browserId = null): BasketBindingResponse
|
||||
{
|
||||
$uri = sprintf('/v1/izi/basket/%s/binding', $basketId);
|
||||
if (null !== $browserId) {
|
||||
$uri .= '?' . self::buildQuery(['browser_id' => $browserId]);
|
||||
}
|
||||
|
||||
$request = $this->createRequest('GET', $uri);
|
||||
$response = $this->sendRequest($request);
|
||||
|
||||
return $this->deserialize($response, BasketBindingResponse::class);
|
||||
}
|
||||
|
||||
public function updateOrder(string $orderId, OrderEvent $event): void
|
||||
{
|
||||
$request = $this->createRequest('POST', sprintf('/v1/izi/order/%s/event', $orderId), $event);
|
||||
// currently the API returns 201 on success instead of 200 given in the documentation
|
||||
$this->sendRequest($request, 200, 201);
|
||||
}
|
||||
|
||||
public function getSigningKey(string $version): SigningKey
|
||||
{
|
||||
$request = $this->createRequest('GET', sprintf('/v1/izi/signing-keys/public/%s', $version));
|
||||
$response = $this->sendRequest($request);
|
||||
|
||||
return $this->deserialize($response, SigningKey::class);
|
||||
}
|
||||
|
||||
public function getSigningKeys(): SigningKeys
|
||||
{
|
||||
$request = $this->createRequest('GET', '/v1/izi/signing-keys/public');
|
||||
$response = $this->sendRequest($request);
|
||||
|
||||
return $this->deserialize($response, SigningKeys::class);
|
||||
}
|
||||
|
||||
public function getAvailablePaymentOptions(): AvailablePaymentOptions
|
||||
{
|
||||
$request = $this->createRequest('GET', '/v1/izi/payment-methods');
|
||||
$response = $this->sendRequest($request);
|
||||
|
||||
return $this->deserialize($response, AvailablePaymentOptions::class);
|
||||
}
|
||||
|
||||
public function createProducts(CreateProductsRequest $products): CreateProductsResponse
|
||||
{
|
||||
$request = $this->createRequest('POST', '/v1/izi/products', $products);
|
||||
$response = $this->sendRequest($request, 201);
|
||||
|
||||
return $this->deserialize($response, CreateProductsResponse::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $productIds
|
||||
*
|
||||
* @return PaginationPage<ResponseProduct>
|
||||
*/
|
||||
public function getProductsPage(array $productIds = [], ?int $pageSize = null, ?int $pageIndex = null): PaginationPage
|
||||
{
|
||||
$params = [];
|
||||
|
||||
if (null !== $pageIndex) {
|
||||
$params['page_index'] = $pageIndex;
|
||||
}
|
||||
|
||||
if (null !== $pageSize) {
|
||||
$params['page_size'] = $pageSize;
|
||||
}
|
||||
|
||||
if ([] !== $productIds) {
|
||||
$params['product_ids'] = implode(',', $productIds);
|
||||
}
|
||||
|
||||
$uri = '/v1/izi/products';
|
||||
if ([] !== $params) {
|
||||
$uri .= '?' . self::buildQuery($params);
|
||||
}
|
||||
|
||||
$request = $this->createRequest('GET', $uri);
|
||||
$response = $this->sendRequest($request);
|
||||
|
||||
return $this->deserialize($response, PaginationPage::class, [
|
||||
BasketAppPaginationPageDenormalizer::ITEM_TYPE_KEY => ResponseProduct::class,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $productIds
|
||||
*
|
||||
* @return \Generator<ResponseProduct>
|
||||
*/
|
||||
public function getProducts(array $productIds = [], ?int $pageSize = null): \Traversable
|
||||
{
|
||||
$pageIndex = 0;
|
||||
|
||||
do {
|
||||
$page = $this->getProductsPage($productIds, $pageSize, $pageIndex++);
|
||||
$pageSize = $page->getPageSize();
|
||||
$totalCount = $page->getTotalCount();
|
||||
|
||||
foreach ($page as $product) {
|
||||
yield $product;
|
||||
}
|
||||
} while ($totalCount > $pageSize * $pageIndex);
|
||||
}
|
||||
|
||||
public function updateProduct(string $productId, Product $product): ResponseProduct
|
||||
{
|
||||
$request = $this->createRequest('PUT', sprintf('/v1/izi/product/%s', $productId), $product);
|
||||
$response = $this->sendRequest($request);
|
||||
|
||||
return $this->deserialize($response, ResponseProduct::class);
|
||||
}
|
||||
|
||||
public function deleteProduct(string $productId): void
|
||||
{
|
||||
$request = $this->createRequest('DELETE', sprintf('/v1/izi/product/%s', $productId));
|
||||
$this->sendRequest($request, 204);
|
||||
}
|
||||
|
||||
private function createRequest(string $method, string $uri, $payload = null): RequestInterface
|
||||
{
|
||||
$uri = UriResolver::resolve($uri, $this->baseUri);
|
||||
|
||||
$request = $this->requestFactory
|
||||
->createRequest($method, $uri)
|
||||
->withHeader('Accept', 'application/json');
|
||||
|
||||
if (null === $payload) {
|
||||
return $request;
|
||||
}
|
||||
|
||||
$payload = $this->serializer->serialize($payload, 'json', [
|
||||
'datetime_format' => self::DATETIME_FORMAT,
|
||||
'datetime_timezone' => self::DATETIME_ZONE,
|
||||
]);
|
||||
|
||||
$body = $this->streamFactory->createStream($payload);
|
||||
|
||||
return $request
|
||||
->withBody($body)
|
||||
->withHeader('Content-Type', 'application/json');
|
||||
}
|
||||
|
||||
private function sendRequest(RequestInterface $request, int $expectedStatusCode = 200, int ...$allowedStatusCodes): ResponseInterface
|
||||
{
|
||||
$response = $this->client->sendRequest($request);
|
||||
$statusCode = $response->getStatusCode();
|
||||
|
||||
if (300 <= $statusCode) {
|
||||
$this->handleUnsuccessfulResponse($request, $response);
|
||||
}
|
||||
|
||||
if ($expectedStatusCode === $statusCode || in_array($statusCode, $allowedStatusCodes, true)) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
throw new \UnexpectedValueException(sprintf('Unexpected server response code: %d', $statusCode));
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
*
|
||||
* @param class-string<T> $class
|
||||
*
|
||||
* @return T
|
||||
*/
|
||||
private function deserialize(ResponseInterface $response, string $class, array $context = [])
|
||||
{
|
||||
return $this->serializer->deserialize((string) $response->getBody(), $class, 'json', $context);
|
||||
}
|
||||
|
||||
private function handleUnsuccessfulResponse(RequestInterface $request, ResponseInterface $response): void
|
||||
{
|
||||
$statusCode = $response->getStatusCode();
|
||||
|
||||
try {
|
||||
$error = $this->deserialize($response, Error::class);
|
||||
|
||||
throw BasketAppException::create($request, $error, $statusCode); // TODO? replace with exception factory service
|
||||
} catch (ExceptionInterface $e) {
|
||||
// ignore deserialization errors
|
||||
}
|
||||
|
||||
if (500 <= $statusCode) {
|
||||
throw new ServerException($request, $response);
|
||||
}
|
||||
|
||||
if (400 <= $statusCode) {
|
||||
throw new ClientException($request, $response);
|
||||
}
|
||||
|
||||
throw new RedirectionException($request, $response);
|
||||
}
|
||||
|
||||
private static function buildQuery(array $params): string
|
||||
{
|
||||
return http_build_query($params, '', '&', PHP_QUERY_RFC3986);
|
||||
}
|
||||
}
|
||||
74
modules/inpostizi/src/BasketApp/BasketAppClientFactory.php
Normal file
74
modules/inpostizi/src/BasketApp/BasketAppClientFactory.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp;
|
||||
|
||||
use izi\prestashop\Configuration\ApiConfigurationInterface;
|
||||
use izi\prestashop\Environment\AuthServerUriCollection;
|
||||
use izi\prestashop\Http\Client\AuthorizingClient;
|
||||
use izi\prestashop\Http\Client\Factory\ClientFactoryInterface;
|
||||
use izi\prestashop\Http\Client\Factory\GuzzleClientFactory;
|
||||
use izi\prestashop\OAuth2\AuthorizationProviderFactoryInterface;
|
||||
use Psr\Http\Client\ClientInterface;
|
||||
use Psr\Http\Message\RequestFactoryInterface;
|
||||
use Psr\Http\Message\StreamFactoryInterface;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
|
||||
final class BasketAppClientFactory
|
||||
{
|
||||
/**
|
||||
* @var RequestFactoryInterface
|
||||
*/
|
||||
private $requestFactory;
|
||||
|
||||
/**
|
||||
* @var StreamFactoryInterface
|
||||
*/
|
||||
private $streamFactory;
|
||||
|
||||
/**
|
||||
* @var SerializerInterface
|
||||
*/
|
||||
private $serializer;
|
||||
|
||||
/**
|
||||
* @var ClientFactoryInterface
|
||||
*/
|
||||
private $clientFactory;
|
||||
|
||||
/**
|
||||
* @var AuthorizationProviderFactoryInterface
|
||||
*/
|
||||
private $authorizationProviderFactory;
|
||||
|
||||
public function __construct(RequestFactoryInterface $requestFactory, StreamFactoryInterface $streamFactory, SerializerInterface $serializer, ?ClientFactoryInterface $clientFactory = null, ?AuthorizationProviderFactoryInterface $authorizationProviderFactory = null)
|
||||
{
|
||||
$this->requestFactory = $requestFactory;
|
||||
$this->streamFactory = $streamFactory;
|
||||
$this->serializer = $serializer;
|
||||
$this->clientFactory = $clientFactory ?? new GuzzleClientFactory();
|
||||
$this->authorizationProviderFactory = $authorizationProviderFactory ?? new AuthorizationProviderFactory($requestFactory, $streamFactory, $this->clientFactory);
|
||||
}
|
||||
|
||||
public function create(ApiConfigurationInterface $configuration): BasketAppClient
|
||||
{
|
||||
$httpClient = $this->createHttpClient($configuration);
|
||||
$baseUri = $configuration->getEnvironment()->getBasketAppApiUri();
|
||||
|
||||
return new BasketAppClient($httpClient, $this->requestFactory, $this->streamFactory, $this->serializer, $baseUri);
|
||||
}
|
||||
|
||||
private function createHttpClient(ApiConfigurationInterface $configuration): ClientInterface
|
||||
{
|
||||
if (null === $credentials = $configuration->getClientCredentials()) {
|
||||
throw new \RuntimeException('Client credentials are not available.');
|
||||
}
|
||||
|
||||
$uriCollection = new AuthServerUriCollection($configuration->getEnvironment());
|
||||
$authorizationProvider = $this->authorizationProviderFactory->create($uriCollection, $credentials);
|
||||
$client = $this->clientFactory->create();
|
||||
|
||||
return new AuthorizingClient($client, $authorizationProvider);
|
||||
}
|
||||
}
|
||||
20
modules/inpostizi/src/BasketApp/BasketAppClientInterface.php
Normal file
20
modules/inpostizi/src/BasketApp/BasketAppClientInterface.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp;
|
||||
|
||||
use izi\prestashop\BasketApp\Basket\BasketsApiClientInterface;
|
||||
use izi\prestashop\BasketApp\Order\OrdersApiClientInterface;
|
||||
use izi\prestashop\BasketApp\Payment\PaymentsApiClientInterface;
|
||||
use izi\prestashop\BasketApp\Product\ProductsApiClientInterface;
|
||||
use izi\prestashop\BasketApp\Signature\SigningKeysApiClientInterface;
|
||||
|
||||
/**
|
||||
* @extends ProductsApiClientInterface
|
||||
*/
|
||||
interface BasketAppClientInterface extends BasketsApiClientInterface, OrdersApiClientInterface, SigningKeysApiClientInterface, PaymentsApiClientInterface
|
||||
{
|
||||
public const DATETIME_FORMAT = 'Y-m-d\TH:i:s.u\Z'; // format character "p" is not available before PHP 8.0
|
||||
public const DATETIME_ZONE = 'UTC';
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Exception;
|
||||
|
||||
class BadRequestException extends BasketAppException
|
||||
{
|
||||
public const ERROR_CODE = 'BAD_REQUEST';
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Exception;
|
||||
|
||||
final class BasketAlreadyBoundException extends BasketAppException
|
||||
{
|
||||
public const ERROR_CODE = 'BASKET_IS_BINDED';
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Exception;
|
||||
|
||||
use izi\prestashop\BasketApp\Product\Exception as Product;
|
||||
use izi\prestashop\Common\Error\Error;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
|
||||
class BasketAppException extends \RuntimeException
|
||||
{
|
||||
/**
|
||||
* @var array<string, class-string<self>> exception class names by error codes
|
||||
*/
|
||||
private const CLASS_MAP = [
|
||||
BadRequestException::ERROR_CODE => BadRequestException::class,
|
||||
MalformedRequestException::ERROR_CODE => MalformedRequestException::class,
|
||||
UnauthorizedException::ERROR_CODE => UnauthorizedException::class,
|
||||
ForbiddenException::ERROR_CODE => ForbiddenException::class,
|
||||
ResourceNotFoundException::ERROR_CODE => ResourceNotFoundException::class,
|
||||
BasketNotFoundException::ERROR_CODE => BasketNotFoundException::class,
|
||||
PublicKeyNotFoundException::ERROR_CODE => PublicKeyNotFoundException::class,
|
||||
OrderNotFoundException::ERROR_CODE => OrderNotFoundException::class,
|
||||
MerchantDisabledException::ERROR_CODE => MerchantDisabledException::class,
|
||||
BasketAlreadyBoundException::ERROR_CODE => BasketAlreadyBoundException::class,
|
||||
PhoneBindingUnavailableException::ERROR_CODE => PhoneBindingUnavailableException::class,
|
||||
BasketNotBoundException::ERROR_CODE => BasketNotBoundException::class,
|
||||
BasketExpiredException::ERROR_CODE => BasketExpiredException::class,
|
||||
CannotChangeOrderStatusException::ERROR_CODE => CannotChangeOrderStatusException::class,
|
||||
InternalServerErrorException::ERROR_CODE => InternalServerErrorException::class,
|
||||
Product\ProductNotFoundException::ERROR_CODE => Product\ProductNotFoundException::class,
|
||||
Product\ProductExistsException::ERROR_CODE => Product\ProductExistsException::class,
|
||||
Product\MaxProductLimitReachedException::ERROR_CODE => Product\MaxProductLimitReachedException::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* @var RequestInterface
|
||||
*/
|
||||
private $request;
|
||||
|
||||
/**
|
||||
* @var Error
|
||||
*/
|
||||
private $error;
|
||||
|
||||
public function __construct(RequestInterface $request, Error $error, int $statusCode)
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->error = $error;
|
||||
|
||||
parent::__construct($error->getMessage(), $statusCode);
|
||||
}
|
||||
|
||||
public static function create(RequestInterface $request, Error $error, int $statusCode): self
|
||||
{
|
||||
$class = self::CLASS_MAP[$error->getCode()] ?? self::class;
|
||||
|
||||
return new $class($request, $error, $statusCode);
|
||||
}
|
||||
|
||||
public function getRequest(): RequestInterface
|
||||
{
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
public function getError(): Error
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Exception;
|
||||
|
||||
final class BasketExpiredException extends BasketAppException
|
||||
{
|
||||
public const ERROR_CODE = 'BASKET_EXPIRED';
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Exception;
|
||||
|
||||
final class BasketNotBoundException extends BasketAppException
|
||||
{
|
||||
public const ERROR_CODE = 'BASKET_NOT_BOUND';
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Exception;
|
||||
|
||||
final class BasketNotFoundException extends ResourceNotFoundException
|
||||
{
|
||||
public const ERROR_CODE = 'BASKET_NOT_FOUND';
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Exception;
|
||||
|
||||
final class CannotChangeOrderStatusException extends BasketAppException
|
||||
{
|
||||
public const ERROR_CODE = 'STATUS_ORDER_ERROR';
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Exception;
|
||||
|
||||
final class ForbiddenException extends BasketAppException
|
||||
{
|
||||
public const ERROR_CODE = 'FORBIDDEN';
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Exception;
|
||||
|
||||
final class InternalServerErrorException extends BasketAppException
|
||||
{
|
||||
public const ERROR_CODE = 'INTERNAL_SERVER_ERROR';
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Exception;
|
||||
|
||||
final class MalformedRequestException extends BadRequestException
|
||||
{
|
||||
public const ERROR_CODE = 'MALFORMED_REQUEST';
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Exception;
|
||||
|
||||
final class MerchantDisabledException extends BasketAppException
|
||||
{
|
||||
public const ERROR_CODE = 'MERCHANT_DISABLE';
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Exception;
|
||||
|
||||
final class OrderNotFoundException extends ResourceNotFoundException
|
||||
{
|
||||
public const ERROR_CODE = 'ORDER_NOT_FOUND';
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Exception;
|
||||
|
||||
final class PhoneBindingUnavailableException extends BasketAppException
|
||||
{
|
||||
public const ERROR_CODE = 'PHONE_BINDING_METHOD_UNAVAILABLE';
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Exception;
|
||||
|
||||
final class PublicKeyNotFoundException extends ResourceNotFoundException
|
||||
{
|
||||
public const ERROR_CODE = 'PUBLIC_KEY_NOT_FOUND';
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Exception;
|
||||
|
||||
class ResourceNotFoundException extends BasketAppException
|
||||
{
|
||||
public const ERROR_CODE = 'NOT_FOUND';
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Exception;
|
||||
|
||||
final class UnauthorizedException extends BasketAppException
|
||||
{
|
||||
public const ERROR_CODE = 'UNAUTHORIZED';
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Order;
|
||||
|
||||
use izi\prestashop\BasketApp\Exception\CannotChangeOrderStatusException;
|
||||
use izi\prestashop\BasketApp\Exception\OrderNotFoundException;
|
||||
use izi\prestashop\BasketApp\Order\Request\OrderEvent;
|
||||
|
||||
interface OrdersApiClientInterface
|
||||
{
|
||||
/**
|
||||
* @throws OrderNotFoundException
|
||||
* @throws CannotChangeOrderStatusException
|
||||
*/
|
||||
public function updateOrder(string $orderId, OrderEvent $event): void;
|
||||
}
|
||||
86
modules/inpostizi/src/BasketApp/Order/Request/Delivery.php
Normal file
86
modules/inpostizi/src/BasketApp/Order/Request/Delivery.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Order\Request;
|
||||
|
||||
use izi\prestashop\Common\Order\DeliveryAddress;
|
||||
use izi\prestashop\Common\PhoneNumber;
|
||||
|
||||
final class Delivery implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* @var \DateTimeImmutable|null
|
||||
*/
|
||||
private $delivery_date;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $mail;
|
||||
|
||||
/**
|
||||
* @var PhoneNumber|null
|
||||
*/
|
||||
private $phone_number;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $delivery_point;
|
||||
|
||||
/**
|
||||
* @var DeliveryAddress|null
|
||||
*/
|
||||
private $delivery_address;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $courier_note;
|
||||
|
||||
public function __construct(?\DateTimeImmutable $delivery_date = null, ?string $mail = null, ?PhoneNumber $phone_number = null, ?string $delivery_point = null, ?DeliveryAddress $delivery_address = null, ?string $courier_note = null)
|
||||
{
|
||||
$this->delivery_date = $delivery_date;
|
||||
$this->mail = $mail;
|
||||
$this->phone_number = $phone_number;
|
||||
$this->delivery_point = $delivery_point;
|
||||
$this->delivery_address = $delivery_address;
|
||||
$this->courier_note = $courier_note;
|
||||
}
|
||||
|
||||
public function getDeliveryDate(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->delivery_date;
|
||||
}
|
||||
|
||||
public function getEmail(): ?string
|
||||
{
|
||||
return $this->mail;
|
||||
}
|
||||
|
||||
public function getPhoneNumber(): ?PhoneNumber
|
||||
{
|
||||
return $this->phone_number;
|
||||
}
|
||||
|
||||
public function getPoint(): ?string
|
||||
{
|
||||
return $this->delivery_point;
|
||||
}
|
||||
|
||||
public function getAddress(): ?DeliveryAddress
|
||||
{
|
||||
return $this->delivery_address;
|
||||
}
|
||||
|
||||
public function getCourierNote(): ?string
|
||||
{
|
||||
return $this->courier_note;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return get_object_vars($this);
|
||||
}
|
||||
}
|
||||
63
modules/inpostizi/src/BasketApp/Order/Request/OrderEvent.php
Normal file
63
modules/inpostizi/src/BasketApp/Order/Request/OrderEvent.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Order\Request;
|
||||
|
||||
use izi\prestashop\Common\PhoneNumber;
|
||||
|
||||
final class OrderEvent implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $event_id;
|
||||
|
||||
/**
|
||||
* @var \DateTimeImmutable
|
||||
*/
|
||||
private $event_data_time;
|
||||
|
||||
/**
|
||||
* @var PhoneNumber|null
|
||||
*/
|
||||
private $phone_number;
|
||||
|
||||
/**
|
||||
* @var OrderEventData
|
||||
*/
|
||||
private $event_data;
|
||||
|
||||
public function __construct(string $event_id, \DateTimeImmutable $event_data_time, OrderEventData $event_data, ?PhoneNumber $phone_number = null)
|
||||
{
|
||||
$this->event_id = $event_id;
|
||||
$this->event_data_time = $event_data_time;
|
||||
$this->phone_number = $phone_number;
|
||||
$this->event_data = $event_data;
|
||||
}
|
||||
|
||||
public function getId(): string
|
||||
{
|
||||
return $this->event_id;
|
||||
}
|
||||
|
||||
public function getDateTime(): \DateTimeImmutable
|
||||
{
|
||||
return $this->event_data_time;
|
||||
}
|
||||
|
||||
public function getPhoneNumber(): ?PhoneNumber
|
||||
{
|
||||
return $this->phone_number;
|
||||
}
|
||||
|
||||
public function getData(): OrderEventData
|
||||
{
|
||||
return $this->event_data;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return get_object_vars($this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Order\Request;
|
||||
|
||||
use izi\prestashop\Common\Order\MerchantOrderStatus;
|
||||
|
||||
final class OrderEventData implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* @var MerchantOrderStatus|null
|
||||
*/
|
||||
private $order_status;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $order_merchant_status_description;
|
||||
|
||||
/**
|
||||
* @var string[]|null
|
||||
*/
|
||||
private $delivery_references_list;
|
||||
|
||||
/**
|
||||
* @var Delivery|null
|
||||
*/
|
||||
private $delivery;
|
||||
|
||||
/**
|
||||
* @param string[]|null $delivery_references_list
|
||||
*/
|
||||
public function __construct(?MerchantOrderStatus $order_status = null, ?string $order_merchant_status_description = null, ?array $delivery_references_list = null, ?Delivery $delivery = null)
|
||||
{
|
||||
$this->order_status = $order_status;
|
||||
$this->order_merchant_status_description = $order_merchant_status_description;
|
||||
$this->delivery_references_list = $delivery_references_list;
|
||||
$this->delivery = $delivery;
|
||||
}
|
||||
|
||||
public function getStatus(): ?MerchantOrderStatus
|
||||
{
|
||||
return $this->order_status;
|
||||
}
|
||||
|
||||
public function getStatusDescription(): ?string
|
||||
{
|
||||
return $this->order_merchant_status_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]|null
|
||||
*/
|
||||
public function getDeliveryReferencesList(): ?array
|
||||
{
|
||||
return $this->delivery_references_list;
|
||||
}
|
||||
|
||||
public function getDelivery(): ?Delivery
|
||||
{
|
||||
return $this->delivery;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return get_object_vars($this);
|
||||
}
|
||||
}
|
||||
83
modules/inpostizi/src/BasketApp/PaginationPage.php
Normal file
83
modules/inpostizi/src/BasketApp/PaginationPage.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp;
|
||||
|
||||
/**
|
||||
* @template T
|
||||
*
|
||||
* @template-implements \IteratorAggregate<int, T>
|
||||
*/
|
||||
final class PaginationPage implements \IteratorAggregate, \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* @var T[]
|
||||
*/
|
||||
private $content;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $total_items;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $page_index;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $page_size;
|
||||
|
||||
/**
|
||||
* @param T[] $content
|
||||
*/
|
||||
public function __construct(array $content, int $total_items, int $page_index, int $page_size)
|
||||
{
|
||||
$this->content = $content;
|
||||
$this->total_items = $total_items;
|
||||
$this->page_index = $page_index;
|
||||
$this->page_size = $page_size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return T[]
|
||||
*/
|
||||
public function getItems(): array
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
public function getTotalCount(): int
|
||||
{
|
||||
return $this->total_items;
|
||||
}
|
||||
|
||||
public function getPageIndex(): int
|
||||
{
|
||||
return $this->page_index;
|
||||
}
|
||||
|
||||
public function getPageSize(): int
|
||||
{
|
||||
return $this->page_size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return get_object_vars($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Traversable<int, T>
|
||||
*/
|
||||
public function getIterator(): \Traversable
|
||||
{
|
||||
return new \ArrayIterator($this->content);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Payment;
|
||||
|
||||
use izi\prestashop\BasketApp\Payment\Response\AvailablePaymentOptions;
|
||||
|
||||
interface PaymentsApiClientInterface
|
||||
{
|
||||
public function getAvailablePaymentOptions(): AvailablePaymentOptions;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Payment\Response;
|
||||
|
||||
use izi\prestashop\Common\PaymentType;
|
||||
|
||||
/**
|
||||
* @implements \IteratorAggregate<PaymentType>
|
||||
*/
|
||||
final class AvailablePaymentOptions implements \JsonSerializable, \IteratorAggregate
|
||||
{
|
||||
/**
|
||||
* @var PaymentType[]
|
||||
*/
|
||||
private $payment_type;
|
||||
|
||||
/**
|
||||
* @param PaymentType[] $payment_type
|
||||
*/
|
||||
public function __construct(array $payment_type)
|
||||
{
|
||||
$this->payment_type = $payment_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PaymentType[]
|
||||
*/
|
||||
public function getPaymentTypes(): array
|
||||
{
|
||||
return $this->payment_type;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return get_object_vars($this);
|
||||
}
|
||||
|
||||
public function getIterator(): \Iterator
|
||||
{
|
||||
return new \ArrayIterator($this->payment_type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Product\Exception;
|
||||
|
||||
use izi\prestashop\BasketApp\Exception\BasketAppException;
|
||||
|
||||
final class MaxProductLimitReachedException extends BasketAppException
|
||||
{
|
||||
public const ERROR_CODE = 'MAX_LIMIT_PRODUCTS';
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Product\Exception;
|
||||
|
||||
use izi\prestashop\BasketApp\Exception\BasketAppException;
|
||||
|
||||
final class ProductExistsException extends BasketAppException
|
||||
{
|
||||
public const ERROR_CODE = 'PRODUCT_EXISTS';
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Product\Exception;
|
||||
|
||||
use izi\prestashop\BasketApp\Exception\BasketAppException;
|
||||
|
||||
final class ProductNotFoundException extends BasketAppException
|
||||
{
|
||||
public const ERROR_CODE = 'PRODUCT_NOT_FOUND';
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Product;
|
||||
|
||||
use izi\prestashop\BasketApp\PaginationPage;
|
||||
use izi\prestashop\BasketApp\Product\Exception\MaxProductLimitReachedException;
|
||||
use izi\prestashop\BasketApp\Product\Exception\ProductExistsException;
|
||||
use izi\prestashop\BasketApp\Product\Exception\ProductNotFoundException;
|
||||
use izi\prestashop\BasketApp\Product\Request\CreateProductsRequest;
|
||||
use izi\prestashop\BasketApp\Product\Response\CreateProductsResponse;
|
||||
use izi\prestashop\BasketApp\Product\Response\Product as ResponseProduct;
|
||||
use izi\prestashop\Common\HotProduct\Product;
|
||||
|
||||
interface ProductsApiClientInterface
|
||||
{
|
||||
/**
|
||||
* Create products in InPost Pay.
|
||||
*
|
||||
* @throws ProductExistsException
|
||||
* @throws MaxProductLimitReachedException
|
||||
*/
|
||||
public function createProducts(CreateProductsRequest $products): CreateProductsResponse;
|
||||
|
||||
/**
|
||||
* Get paginated list of products from InPost Pay.
|
||||
*
|
||||
* @param string[] $productIds optional list of product IDs to filter by
|
||||
*
|
||||
* @return PaginationPage<ResponseProduct>
|
||||
*/
|
||||
public function getProductsPage(array $productIds = [], ?int $pageSize = null, ?int $pageIndex = null): PaginationPage;
|
||||
|
||||
/**
|
||||
* Get InPost Pay products iterator.
|
||||
*
|
||||
* @param string[] $productIds optional list of product IDs to filter by
|
||||
*
|
||||
* @return \Traversable<ResponseProduct>
|
||||
*/
|
||||
public function getProducts(array $productIds = [], ?int $pageSize = null): \Traversable;
|
||||
|
||||
/**
|
||||
* Update a product in InPost Pay.
|
||||
*
|
||||
* @throws ProductNotFoundException
|
||||
*/
|
||||
public function updateProduct(string $productId, Product $product): ResponseProduct;
|
||||
|
||||
/**
|
||||
* Delete a product from InPost Pay.
|
||||
*
|
||||
* @throws ProductNotFoundException
|
||||
*/
|
||||
public function deleteProduct(string $productId): void;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Product\Request;
|
||||
|
||||
use izi\prestashop\Common\HotProduct\IdentifiableProduct;
|
||||
|
||||
final class CreateProductsRequest implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* @var IdentifiableProduct[]
|
||||
*/
|
||||
private $content;
|
||||
|
||||
/**
|
||||
* @param IdentifiableProduct[] $content
|
||||
*/
|
||||
public function __construct(array $content)
|
||||
{
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return IdentifiableProduct[]
|
||||
*/
|
||||
public function getProducts(): array
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return get_object_vars($this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Product\Response;
|
||||
|
||||
final class CreateProductsResponse implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* @var ProductId[]
|
||||
*/
|
||||
private $content;
|
||||
|
||||
/**
|
||||
* @param ProductId[] $content
|
||||
*/
|
||||
public function __construct(array $content)
|
||||
{
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ProductId[]
|
||||
*/
|
||||
public function getProductIds(): array
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return get_object_vars($this);
|
||||
}
|
||||
}
|
||||
191
modules/inpostizi/src/BasketApp/Product/Response/Product.php
Normal file
191
modules/inpostizi/src/BasketApp/Product/Response/Product.php
Normal file
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Product\Response;
|
||||
|
||||
use izi\prestashop\Common\Currency;
|
||||
use izi\prestashop\Common\HotProduct\ProductAvailability;
|
||||
use izi\prestashop\Common\HotProduct\Quantity;
|
||||
use izi\prestashop\Common\Price;
|
||||
use izi\prestashop\Common\Product\ProductAttribute;
|
||||
use izi\prestashop\Common\Product\ProductImage;
|
||||
|
||||
final class Product implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $product_id;
|
||||
|
||||
/**
|
||||
* @var Status
|
||||
*/
|
||||
private $status;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $ean;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $qr_code;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $deep_link;
|
||||
|
||||
/**
|
||||
* @var ProductAvailability|null
|
||||
*/
|
||||
private $product_availability;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $product_name;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $product_description;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $product_image;
|
||||
|
||||
/**
|
||||
* @var ProductImage[]
|
||||
*/
|
||||
private $additional_product_images;
|
||||
|
||||
/**
|
||||
* @var Price
|
||||
*/
|
||||
private $price;
|
||||
|
||||
/**
|
||||
* @var Currency
|
||||
*/
|
||||
private $currency;
|
||||
|
||||
/**
|
||||
* @var Quantity
|
||||
*/
|
||||
private $quantity;
|
||||
|
||||
/**
|
||||
* @var ProductAttribute[]
|
||||
*/
|
||||
private $product_attributes;
|
||||
|
||||
/**
|
||||
* @param ProductImage[] $additional_product_images
|
||||
* @param ProductAttribute[] $product_attributes
|
||||
*/
|
||||
public function __construct(string $product_id, Status $status, string $product_name, string $product_description, string $product_image, Price $price, Currency $currency, Quantity $quantity, ?string $ean = null, ?string $qr_code = null, ?string $deep_link = null, ?ProductAvailability $product_availability = null, array $additional_product_images = [], array $product_attributes = [])
|
||||
{
|
||||
$this->product_id = $product_id;
|
||||
$this->status = $status;
|
||||
$this->product_name = $product_name;
|
||||
$this->product_description = $product_description;
|
||||
$this->product_image = $product_image;
|
||||
$this->price = $price;
|
||||
$this->currency = $currency;
|
||||
$this->quantity = $quantity;
|
||||
$this->ean = $ean;
|
||||
$this->qr_code = $qr_code;
|
||||
$this->deep_link = $deep_link;
|
||||
$this->product_availability = $product_availability;
|
||||
$this->additional_product_images = $additional_product_images;
|
||||
$this->product_attributes = $product_attributes;
|
||||
}
|
||||
|
||||
public function getId(): string
|
||||
{
|
||||
return $this->product_id;
|
||||
}
|
||||
|
||||
public function getStatus(): Status
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
public function getEan(): ?string
|
||||
{
|
||||
return $this->ean;
|
||||
}
|
||||
|
||||
public function getQrCode(): ?string
|
||||
{
|
||||
return $this->qr_code;
|
||||
}
|
||||
|
||||
public function getDeepLink(): ?string
|
||||
{
|
||||
return $this->deep_link;
|
||||
}
|
||||
|
||||
public function getAvailability(): ?ProductAvailability
|
||||
{
|
||||
return $this->product_availability;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->product_name;
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return $this->product_description;
|
||||
}
|
||||
|
||||
public function getImageUrl(): string
|
||||
{
|
||||
return $this->product_image;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ProductImage[]
|
||||
*/
|
||||
public function getAdditionalImages(): array
|
||||
{
|
||||
return $this->additional_product_images;
|
||||
}
|
||||
|
||||
public function getPrice(): Price
|
||||
{
|
||||
return $this->price;
|
||||
}
|
||||
|
||||
public function getCurrency(): Currency
|
||||
{
|
||||
return $this->currency;
|
||||
}
|
||||
|
||||
public function getQuantity(): Quantity
|
||||
{
|
||||
return $this->quantity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ProductAttribute[]
|
||||
*/
|
||||
public function getAttributes(): array
|
||||
{
|
||||
return $this->product_attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return get_object_vars($this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Product\Response;
|
||||
|
||||
final class ProductId implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $product_id;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $qr_code;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $deep_link;
|
||||
|
||||
public function __construct(string $product_id, ?string $qr_code = null, ?string $deep_link = null)
|
||||
{
|
||||
$this->product_id = $product_id;
|
||||
$this->qr_code = $qr_code;
|
||||
$this->deep_link = $deep_link;
|
||||
}
|
||||
|
||||
public function getId(): string
|
||||
{
|
||||
return $this->product_id;
|
||||
}
|
||||
|
||||
public function getQrCode(): ?string
|
||||
{
|
||||
return $this->qr_code;
|
||||
}
|
||||
|
||||
public function getDeepLink(): ?string
|
||||
{
|
||||
return $this->deep_link;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return get_object_vars($this);
|
||||
}
|
||||
}
|
||||
17
modules/inpostizi/src/BasketApp/Product/Response/Status.php
Normal file
17
modules/inpostizi/src/BasketApp/Product/Response/Status.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Product\Response;
|
||||
|
||||
use izi\prestashop\Enum\StringEnum;
|
||||
|
||||
/**
|
||||
* @method static self Active()
|
||||
* @method static self Inactive()
|
||||
*/
|
||||
final class Status extends StringEnum
|
||||
{
|
||||
public const ACTIVE = 'ACTIVE';
|
||||
public const INACTIVE = 'INACTIVE';
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Signature\Response;
|
||||
|
||||
use izi\prestashop\Serializer\Normalizer\DenormalizableInterface;
|
||||
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
|
||||
|
||||
final class PublicKey implements \JsonSerializable, DenormalizableInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $public_key_base64;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $version;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $hash;
|
||||
|
||||
public function __construct(string $public_key_base64, string $version)
|
||||
{
|
||||
$this->public_key_base64 = $public_key_base64;
|
||||
$this->version = $version;
|
||||
}
|
||||
|
||||
public static function denormalize(array $data): self
|
||||
{
|
||||
if (!isset($data['public_key_base64'], $data['version'])) {
|
||||
throw new UnexpectedValueException('Array data does not contain all of the required parameters.');
|
||||
}
|
||||
|
||||
$key = new self($data['public_key_base64'], $data['version']);
|
||||
if (isset($data['hash'])) {
|
||||
$key->hash = $data['hash'];
|
||||
}
|
||||
|
||||
return $key;
|
||||
}
|
||||
|
||||
public function getBase64Encoded(): string
|
||||
{
|
||||
return $this->public_key_base64;
|
||||
}
|
||||
|
||||
public function getVersion(): string
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return get_object_vars($this);
|
||||
}
|
||||
|
||||
public function getHash(): string
|
||||
{
|
||||
return $this->hash ?? ($this->hash = hash('sha256', $this->public_key_base64));
|
||||
}
|
||||
|
||||
public function getPemFormatted(): string
|
||||
{
|
||||
return "-----BEGIN PUBLIC KEY-----\n" . $this->public_key_base64 . "\n-----END PUBLIC KEY-----";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Signature\Response;
|
||||
|
||||
final class SigningKey implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $merchant_external_id;
|
||||
|
||||
/**
|
||||
* @var PublicKey
|
||||
*/
|
||||
private $public_key;
|
||||
|
||||
public function __construct(string $merchant_external_id, PublicKey $public_key)
|
||||
{
|
||||
$this->merchant_external_id = $merchant_external_id;
|
||||
$this->public_key = $public_key;
|
||||
}
|
||||
|
||||
public function getMerchantId(): string
|
||||
{
|
||||
return $this->merchant_external_id;
|
||||
}
|
||||
|
||||
public function getPublicKey(): PublicKey
|
||||
{
|
||||
return $this->public_key;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return get_object_vars($this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Signature\Response;
|
||||
|
||||
/**
|
||||
* @implements \IteratorAggregate<PublicKey>
|
||||
*/
|
||||
final class SigningKeys implements \IteratorAggregate, \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $merchant_external_id;
|
||||
|
||||
/**
|
||||
* @var PublicKey[]
|
||||
*/
|
||||
private $public_keys;
|
||||
|
||||
/**
|
||||
* @param PublicKey[] $public_keys
|
||||
*/
|
||||
public function __construct(string $merchant_external_id, array $public_keys)
|
||||
{
|
||||
$this->merchant_external_id = $merchant_external_id;
|
||||
$this->public_keys = $public_keys;
|
||||
}
|
||||
|
||||
public function getMerchantId(): string
|
||||
{
|
||||
return $this->merchant_external_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PublicKey[]
|
||||
*/
|
||||
public function getPublicKeys(): array
|
||||
{
|
||||
return $this->public_keys;
|
||||
}
|
||||
|
||||
public function getIterator(): \Iterator
|
||||
{
|
||||
return new \ArrayIterator($this->public_keys);
|
||||
}
|
||||
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return get_object_vars($this);
|
||||
}
|
||||
|
||||
public function getPublicKey(string $version): ?PublicKey
|
||||
{
|
||||
foreach ($this->public_keys as $publicKey) {
|
||||
if ($version === $publicKey->getVersion()) {
|
||||
return $publicKey;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\BasketApp\Signature;
|
||||
|
||||
use izi\prestashop\BasketApp\Exception\PublicKeyNotFoundException;
|
||||
use izi\prestashop\BasketApp\Signature\Response\SigningKey;
|
||||
use izi\prestashop\BasketApp\Signature\Response\SigningKeys;
|
||||
|
||||
interface SigningKeysApiClientInterface
|
||||
{
|
||||
/**
|
||||
* @throws PublicKeyNotFoundException
|
||||
*/
|
||||
public function getSigningKey(string $version): SigningKey;
|
||||
|
||||
public function getSigningKeys(): SigningKeys;
|
||||
}
|
||||
1008
modules/inpostizi/src/Builder/Basket/AbstractBasketBuilder.php
Normal file
1008
modules/inpostizi/src/Builder/Basket/AbstractBasketBuilder.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Builder\Basket;
|
||||
|
||||
use izi\prestashop\BasketApp\Basket\Request\Basket;
|
||||
use izi\prestashop\Common\Basket\AvailablePromotion;
|
||||
use izi\prestashop\Common\Basket\Consent;
|
||||
use izi\prestashop\Common\Basket\DeliveryOption;
|
||||
use izi\prestashop\Common\Basket\Product;
|
||||
use izi\prestashop\Common\Basket\Summary;
|
||||
use izi\prestashop\Common\PromoCode;
|
||||
|
||||
final class BasketAppRequestBuilder extends AbstractBasketBuilder implements BasketAppRequestBuilderInterface
|
||||
{
|
||||
public function build(): Basket
|
||||
{
|
||||
return parent::build();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DeliveryOption[] $delivery
|
||||
* @param Product[] $products
|
||||
* @param Consent[] $consents
|
||||
* @param PromoCode[] $promoCodes
|
||||
* @param Product[] $relatedProducts
|
||||
* @param AvailablePromotion[] $availablePromotions
|
||||
*/
|
||||
protected function doBuild(Summary $summary, array $delivery, array $products, array $consents, array $promoCodes, array $relatedProducts, array $availablePromotions = []): Basket
|
||||
{
|
||||
return new Basket(
|
||||
$summary,
|
||||
$delivery,
|
||||
$products,
|
||||
$consents,
|
||||
$promoCodes,
|
||||
$relatedProducts,
|
||||
$availablePromotions
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Builder\Basket;
|
||||
|
||||
use izi\prestashop\BasketApp\Basket\Request\Basket;
|
||||
|
||||
/**
|
||||
* @template-extends BasketBuilderInterface<Basket>
|
||||
*/
|
||||
interface BasketAppRequestBuilderInterface extends BasketBuilderInterface
|
||||
{
|
||||
public function build(): Basket;
|
||||
}
|
||||
176
modules/inpostizi/src/Builder/Basket/BasketBuilderFactory.php
Normal file
176
modules/inpostizi/src/Builder/Basket/BasketBuilderFactory.php
Normal file
@@ -0,0 +1,176 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Builder\Basket;
|
||||
|
||||
use izi\prestashop\Builder\Basket\BasketAppRequestBuilderInterface as RequestBuilder;
|
||||
use izi\prestashop\Builder\Basket\MerchantApiResponseBuilderInterface as ResponseBuilder;
|
||||
use izi\prestashop\Configuration\ConsentsConfigurationInterface;
|
||||
use izi\prestashop\Configuration\ProductConfigurationInterface;
|
||||
use izi\prestashop\ContextManager;
|
||||
use izi\prestashop\Entities\BasketInterface;
|
||||
use izi\prestashop\Module\ModuleRepository;
|
||||
use izi\prestashop\Product\Price\LowestPriceProviderFactory;
|
||||
use izi\prestashop\Product\Price\LowestPriceProviderInterface;
|
||||
use izi\prestashop\PromoCode\AvailablePromotionsProviderInterface;
|
||||
use izi\prestashop\PromoCode\CartRulePromoCodeProvider;
|
||||
use izi\prestashop\PromoCode\NullAvailablePromotionsProvider;
|
||||
use izi\prestashop\PromoCode\PromoCodeProviderInterface;
|
||||
use Psr\Clock\ClockInterface;
|
||||
use Psr\Log\NullLogger;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
|
||||
final class BasketBuilderFactory implements BasketBuilderFactoryInterface
|
||||
{
|
||||
/**
|
||||
* @var ClockInterface
|
||||
*/
|
||||
private $clock;
|
||||
|
||||
/**
|
||||
* @var ContextManager
|
||||
*/
|
||||
private $contextManager;
|
||||
|
||||
/**
|
||||
* @var ConsentsConfigurationInterface
|
||||
*/
|
||||
private $consentsConfiguration;
|
||||
|
||||
/**
|
||||
* @var ProductConfigurationInterface
|
||||
*/
|
||||
private $productConfiguration;
|
||||
|
||||
/**
|
||||
* @var DeliveryFactory
|
||||
*/
|
||||
private $deliveryFactory;
|
||||
|
||||
/**
|
||||
* @var ProductDeliveryFactory
|
||||
*/
|
||||
private $deliveryRelatedProductFactory;
|
||||
|
||||
/**
|
||||
* @var LowestPriceProviderInterface
|
||||
*/
|
||||
private $lowestPriceProvider;
|
||||
|
||||
/**
|
||||
* @var PromoCodeProviderInterface
|
||||
*/
|
||||
private $promoCodeProvider;
|
||||
|
||||
/**
|
||||
* @var AvailablePromotionsProviderInterface
|
||||
*/
|
||||
private $availablePromotionsProvider;
|
||||
|
||||
/**
|
||||
* @var ValidatorInterface|null
|
||||
*/
|
||||
private $validator;
|
||||
|
||||
public function __construct(
|
||||
ClockInterface $clock,
|
||||
ContextManager $contextManager,
|
||||
ConsentsConfigurationInterface $consentsConfiguration,
|
||||
ProductConfigurationInterface $productConfiguration,
|
||||
DeliveryFactory $deliveryFactory,
|
||||
ProductDeliveryFactory $deliveryRelatedProductFactory,
|
||||
?LowestPriceProviderInterface $lowestPriceProvider = null,
|
||||
?PromoCodeProviderInterface $promoCodeProvider = null,
|
||||
?AvailablePromotionsProviderInterface $availablePromotionsProvider = null,
|
||||
?ValidatorInterface $validator = null
|
||||
) {
|
||||
$this->clock = $clock;
|
||||
$this->contextManager = $contextManager;
|
||||
$this->consentsConfiguration = $consentsConfiguration;
|
||||
$this->productConfiguration = $productConfiguration;
|
||||
$this->deliveryFactory = $deliveryFactory;
|
||||
$this->deliveryRelatedProductFactory = $deliveryRelatedProductFactory;
|
||||
$this->lowestPriceProvider = $lowestPriceProvider ?? $this->createLowestPriceProvider();
|
||||
$this->promoCodeProvider = $promoCodeProvider ?? CartRulePromoCodeProvider::create();
|
||||
$this->availablePromotionsProvider = $availablePromotionsProvider ?? new NullAvailablePromotionsProvider();
|
||||
$this->validator = $validator;
|
||||
}
|
||||
|
||||
public function createRequestBuilder(BasketInterface $basket, ?int $shopId = null): RequestBuilder
|
||||
{
|
||||
$cart = $this->getCart($basket);
|
||||
|
||||
$builder = new BasketAppRequestBuilder(
|
||||
$cart,
|
||||
$this->contextManager,
|
||||
$this->consentsConfiguration,
|
||||
$this->productConfiguration,
|
||||
$this->deliveryFactory,
|
||||
$this->deliveryRelatedProductFactory,
|
||||
null,
|
||||
$this->lowestPriceProvider,
|
||||
$this->promoCodeProvider,
|
||||
$this->availablePromotionsProvider,
|
||||
$this->validator
|
||||
);
|
||||
|
||||
if (null !== $shopId) {
|
||||
$builder->setShopId($shopId);
|
||||
}
|
||||
|
||||
return $builder->setExpirationDate($this->getExpirationDate());
|
||||
}
|
||||
|
||||
public function createResponseBuilder(BasketInterface $basket, ?int $shopId = null): ResponseBuilder
|
||||
{
|
||||
$cart = $this->getCart($basket);
|
||||
|
||||
$builder = new MerchantApiResponseBuilder(
|
||||
$cart,
|
||||
$this->contextManager,
|
||||
$this->consentsConfiguration,
|
||||
$this->productConfiguration,
|
||||
$this->deliveryFactory,
|
||||
$this->deliveryRelatedProductFactory,
|
||||
null,
|
||||
$this->lowestPriceProvider,
|
||||
$this->promoCodeProvider,
|
||||
$this->availablePromotionsProvider,
|
||||
$this->validator
|
||||
);
|
||||
|
||||
if (null !== $shopId) {
|
||||
$builder->setShopId($shopId);
|
||||
}
|
||||
|
||||
return $builder->setExpirationDate($this->getExpirationDate());
|
||||
}
|
||||
|
||||
private function getCart(BasketInterface $basket): \Cart
|
||||
{
|
||||
$cart = $basket->getEntity();
|
||||
|
||||
if (!$cart instanceof \Cart) {
|
||||
throw new \InvalidArgumentException(sprintf('Expected basket entity to be an instance of "%s", "%s" given.', \Cart::class, get_class($cart)));
|
||||
}
|
||||
|
||||
return $cart;
|
||||
}
|
||||
|
||||
// TODO configurable?
|
||||
private function getExpirationDate(): \DateTimeImmutable
|
||||
{
|
||||
return $this->clock->now()->add(new \DateInterval('P2D'));
|
||||
}
|
||||
|
||||
private function createLowestPriceProvider(): LowestPriceProviderInterface
|
||||
{
|
||||
$repository = new ModuleRepository();
|
||||
|
||||
$module = $repository->findByName('inpostizi');
|
||||
$logger = $module ? $module->getLogger() : new NullLogger();
|
||||
|
||||
return (new LowestPriceProviderFactory($repository, $logger))->create();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Builder\Basket;
|
||||
|
||||
use izi\prestashop\Builder\Basket\BasketAppRequestBuilderInterface as RequestBuilder;
|
||||
use izi\prestashop\Builder\Basket\MerchantApiResponseBuilderInterface as ResponseBuilder;
|
||||
use izi\prestashop\Entities\BasketInterface;
|
||||
|
||||
interface BasketBuilderFactoryInterface
|
||||
{
|
||||
public function createRequestBuilder(BasketInterface $basket): RequestBuilder;
|
||||
|
||||
public function createResponseBuilder(BasketInterface $basket): ResponseBuilder;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Builder\Basket;
|
||||
|
||||
use izi\prestashop\Common\Basket\Notice;
|
||||
|
||||
/**
|
||||
* @template T of object
|
||||
*/
|
||||
interface BasketBuilderInterface
|
||||
{
|
||||
/**
|
||||
* @return T
|
||||
*/
|
||||
public function build();
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function setExpirationDate(?\DateTimeImmutable $expirationDate): self;
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function setNotice(?Notice $notice): self;
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function setAdditionalInformation(?string $info): self;
|
||||
}
|
||||
214
modules/inpostizi/src/Builder/Basket/DeliveryFactory.php
Normal file
214
modules/inpostizi/src/Builder/Basket/DeliveryFactory.php
Normal file
@@ -0,0 +1,214 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Builder\Basket;
|
||||
|
||||
use izi\prestashop\Builder\PriceFactory;
|
||||
use izi\prestashop\Common\Basket\DeliveryOption;
|
||||
use izi\prestashop\Common\Delivery\DeliveryType;
|
||||
use izi\prestashop\Common\Delivery\OptionalService;
|
||||
use izi\prestashop\Common\Delivery\ServiceCode;
|
||||
use izi\prestashop\Common\Price;
|
||||
use izi\prestashop\Configuration\DTO\Shipping\ServiceOptions;
|
||||
use izi\prestashop\Configuration\DTO\Shipping\ShippingOptions;
|
||||
use izi\prestashop\Configuration\ShippingConfigurationInterface;
|
||||
use izi\prestashop\ObjectModel\Repository\CarrierRepository;
|
||||
use izi\prestashop\ObjectModel\Repository\ObjectRepositoryInterface;
|
||||
use izi\prestashop\Shipping\DeliveryPriceCalculatorInterface;
|
||||
use izi\prestashop\Translation\ServiceNameTranslator;
|
||||
use Psr\Clock\ClockInterface;
|
||||
|
||||
class DeliveryFactory
|
||||
{
|
||||
/**
|
||||
* @var ShippingConfigurationInterface
|
||||
*/
|
||||
private $configuration;
|
||||
|
||||
/**
|
||||
* @var CarrierRepository
|
||||
*/
|
||||
private $carrierRepository;
|
||||
|
||||
/**
|
||||
* @var ClockInterface
|
||||
*/
|
||||
private $clock;
|
||||
|
||||
/**
|
||||
* @var ServiceNameTranslator
|
||||
*/
|
||||
private $serviceNameTranslator;
|
||||
|
||||
/**
|
||||
* @var DeliveryPriceCalculatorInterface
|
||||
*/
|
||||
private $priceCalculator;
|
||||
|
||||
/**
|
||||
* @param CarrierRepository $carrierRepository
|
||||
*/
|
||||
public function __construct(ShippingConfigurationInterface $configuration, ObjectRepositoryInterface $carrierRepository, ClockInterface $clock, ServiceNameTranslator $serviceNameTranslator, DeliveryPriceCalculatorInterface $priceCalculator)
|
||||
{
|
||||
$this->configuration = $configuration;
|
||||
$this->carrierRepository = $carrierRepository;
|
||||
$this->clock = $clock;
|
||||
$this->serviceNameTranslator = $serviceNameTranslator;
|
||||
$this->priceCalculator = $priceCalculator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DeliveryOption[]
|
||||
*/
|
||||
public function getAvailableDeliveryOptions(\Cart $cart, ?int $idShop = null): array
|
||||
{
|
||||
$deliveryOptions = [];
|
||||
$idShop = $idShop ?? (int) $cart->id_shop;
|
||||
|
||||
$deliveryDate = $this->getDeliveryDate();
|
||||
$isFreeShipping = null;
|
||||
|
||||
foreach (DeliveryType::cases() as $deliveryType) {
|
||||
$options = $this->configuration->getShippingOptions($deliveryType, (int) $idShop);
|
||||
$referenceId = $options->getCarrierMapping()->getReferenceId();
|
||||
|
||||
if (null === $referenceId || null === $carrier = $this->getCarrier($cart, $referenceId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($isFreeShipping)) {
|
||||
$isFreeShipping = $this->hasFreeShippingCartRule($cart);
|
||||
}
|
||||
|
||||
$price = $isFreeShipping
|
||||
? PriceFactory::create(0., 0.)
|
||||
: $this->priceCalculator->getDeliveryPrice($cart, $carrier);
|
||||
|
||||
$deliveryOptions[] = new DeliveryOption(
|
||||
$deliveryType,
|
||||
$deliveryDate,
|
||||
$price,
|
||||
$this->getOptionalServices($deliveryType, $cart, $options, $carrier, $isFreeShipping),
|
||||
$this->priceCalculator->getFreeDeliveryMinAmount($cart, $carrier)
|
||||
);
|
||||
}
|
||||
|
||||
return $deliveryOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return OptionalService[]
|
||||
*/
|
||||
private function getOptionalServices(DeliveryType $deliveryType, \Cart $cart, ShippingOptions $options, \Carrier $defaultCarrier, bool $isFreeShipping): array
|
||||
{
|
||||
$services = [];
|
||||
|
||||
foreach ($deliveryType->getAvailableServiceCodes() as $serviceCode) {
|
||||
if (null === $carrierId = $options->getCarrierMapping($serviceCode)->getReferenceId()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$serviceOptions = $options->getServiceOptions($serviceCode);
|
||||
|
||||
if (null === $serviceOptions || !$this->checkServiceAvailability($serviceCode, $serviceOptions)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($carrierId === (int) $defaultCarrier->id_reference) {
|
||||
$carrier = $defaultCarrier;
|
||||
} elseif (null === $carrier = $this->getCarrier($cart, $carrierId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$servicePrice = $this->getServicePrice($serviceOptions, $cart, $carrier, $defaultCarrier, $isFreeShipping);
|
||||
|
||||
if (0 > $servicePrice->getNet()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$services[] = new OptionalService(
|
||||
$this->serviceNameTranslator->getName($serviceCode),
|
||||
$serviceCode,
|
||||
$servicePrice
|
||||
);
|
||||
}
|
||||
|
||||
return $services;
|
||||
}
|
||||
|
||||
private function getServicePrice(ServiceOptions $options, \Cart $cart, \Carrier $carrier, \Carrier $defaultCarrier, bool $isFreeShipping): Price
|
||||
{
|
||||
if ($isFreeShipping) {
|
||||
return PriceFactory::create(0., 0.);
|
||||
}
|
||||
|
||||
$servicePrice = $this->priceCalculator->getAdditionalServicePrice($cart, $carrier, $options);
|
||||
|
||||
if ($carrier === $defaultCarrier) {
|
||||
return $servicePrice;
|
||||
}
|
||||
|
||||
$carrierPrice = $this->priceCalculator->getDeliveryPrice($cart, $carrier);
|
||||
$defaultCarrierPrice = $this->priceCalculator->getDeliveryPrice($cart, $defaultCarrier);
|
||||
|
||||
return $servicePrice
|
||||
->add($carrierPrice)
|
||||
->sub($defaultCarrierPrice);
|
||||
}
|
||||
|
||||
private function checkServiceAvailability(ServiceCode $serviceCode, ServiceOptions $options): bool
|
||||
{
|
||||
if (!$serviceCode->isAvailabilityTimeDependent()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$availability = $options->getAvailabilityRange();
|
||||
|
||||
return null === $availability
|
||||
|| $availability->contains($this->clock->now());
|
||||
}
|
||||
|
||||
private function isDeliveryOptionAvailable(\Cart $cart, int $carrierId): bool
|
||||
{
|
||||
$deliveryOptionList = $cart->getDeliveryOptionList();
|
||||
$addressId = (int) $cart->id_address_delivery;
|
||||
|
||||
if (!isset($deliveryOptionList[$addressId])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($deliveryOptionList[$addressId] as $option) {
|
||||
if (isset($option['carrier_list'][$carrierId]) && 1 === count($option['carrier_list'])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function hasFreeShippingCartRule(\Cart $cart): bool
|
||||
{
|
||||
return [] !== $cart->getCartRules(\CartRule::FILTER_ACTION_SHIPPING, false);
|
||||
}
|
||||
|
||||
private function getCarrier(\Cart $cart, int $referenceId): ?\Carrier
|
||||
{
|
||||
$carrier = $this->carrierRepository->findOneByReferenceId($referenceId);
|
||||
|
||||
if (null === $carrier || !$this->isDeliveryOptionAvailable($cart, (int) $carrier->id)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $carrier;
|
||||
}
|
||||
|
||||
// TODO make configurable?
|
||||
private function getDeliveryDate(): \DateTimeImmutable
|
||||
{
|
||||
return $this->clock
|
||||
->now()
|
||||
->modify('+2 days')
|
||||
->setTime(12, 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Builder\Basket;
|
||||
|
||||
use izi\prestashop\Common\Basket\AvailablePromotion;
|
||||
use izi\prestashop\Common\Basket\Consent;
|
||||
use izi\prestashop\Common\Basket\DeliveryOption;
|
||||
use izi\prestashop\Common\Basket\Product;
|
||||
use izi\prestashop\Common\Basket\Summary;
|
||||
use izi\prestashop\Common\PromoCode;
|
||||
use izi\prestashop\MerchantApi\Model\Basket\Response\Basket;
|
||||
|
||||
final class MerchantApiResponseBuilder extends AbstractBasketBuilder implements MerchantApiResponseBuilderInterface
|
||||
{
|
||||
public function build(): Basket
|
||||
{
|
||||
return parent::build();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DeliveryOption[] $delivery
|
||||
* @param Product[] $products
|
||||
* @param Consent[] $consents
|
||||
* @param PromoCode[] $promoCodes
|
||||
* @param Product[] $relatedProducts
|
||||
* @param AvailablePromotion[] $availablePromotions
|
||||
*/
|
||||
protected function doBuild(Summary $summary, array $delivery, array $products, array $consents, array $promoCodes, array $relatedProducts, array $availablePromotions = []): Basket
|
||||
{
|
||||
return new Basket(
|
||||
$summary,
|
||||
$delivery,
|
||||
$products,
|
||||
$consents,
|
||||
$promoCodes,
|
||||
$relatedProducts,
|
||||
$availablePromotions
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Builder\Basket;
|
||||
|
||||
use izi\prestashop\MerchantApi\Model\Basket\Response\Basket;
|
||||
|
||||
/**
|
||||
* @template-extends BasketBuilderInterface<Basket>
|
||||
*/
|
||||
interface MerchantApiResponseBuilderInterface extends BasketBuilderInterface
|
||||
{
|
||||
public function build(): Basket;
|
||||
}
|
||||
215
modules/inpostizi/src/Builder/Basket/ProductDeliveryFactory.php
Normal file
215
modules/inpostizi/src/Builder/Basket/ProductDeliveryFactory.php
Normal file
@@ -0,0 +1,215 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Builder\Basket;
|
||||
|
||||
use izi\prestashop\Common\Basket\Quantity;
|
||||
use izi\prestashop\Common\Basket\Summary;
|
||||
use izi\prestashop\Common\Delivery\DeliveryType;
|
||||
use izi\prestashop\Common\Dimensions;
|
||||
use izi\prestashop\Common\Price;
|
||||
use izi\prestashop\Common\Product\DeliveryProduct;
|
||||
use izi\prestashop\Common\Product\DeliveryRelatedProducts;
|
||||
use izi\prestashop\Common\Weight;
|
||||
use izi\prestashop\Configuration\ShippingConfigurationInterface;
|
||||
use izi\prestashop\ObjectModel\Repository\CarrierRepository;
|
||||
use izi\prestashop\ObjectModel\Repository\ObjectRepositoryInterface;
|
||||
use izi\prestashop\Shipping\CartTotal\CartTotalDeliveryStrategyInterface;
|
||||
use izi\prestashop\Shipping\CartWeight\CartWeightDeliveryStrategyInterface;
|
||||
use izi\prestashop\Shipping\ProductDimensions\ProductDimensionsDeliveryStrategyInterface;
|
||||
use izi\prestashop\Shipping\ProductRestriction\ProductRestrictionDeliveryInterface;
|
||||
|
||||
class ProductDeliveryFactory
|
||||
{
|
||||
private $cartBaseWeight = [];
|
||||
|
||||
/**
|
||||
* @var ShippingConfigurationInterface
|
||||
*/
|
||||
private $configuration;
|
||||
|
||||
/**
|
||||
* @var ObjectRepositoryInterface<\Carrier>
|
||||
*/
|
||||
private $carrierRepository;
|
||||
|
||||
/**
|
||||
* @var CartTotalDeliveryStrategyInterface
|
||||
*/
|
||||
private $cartTotalDeliveryStrategy;
|
||||
|
||||
/**
|
||||
* @var CartWeightDeliveryStrategyInterface
|
||||
*/
|
||||
private $cartWeightDeliveryStrategy;
|
||||
|
||||
/**
|
||||
* @var ProductDimensionsDeliveryStrategyInterface
|
||||
*/
|
||||
private $productDimensionsDeliveryStrategy;
|
||||
|
||||
/**
|
||||
* @var ProductRestrictionDeliveryInterface
|
||||
*/
|
||||
private $productRestrictionDelivery;
|
||||
|
||||
/**
|
||||
* @param CarrierRepository $carrierRepository
|
||||
*/
|
||||
public function __construct(
|
||||
ShippingConfigurationInterface $configuration,
|
||||
ObjectRepositoryInterface $carrierRepository,
|
||||
CartTotalDeliveryStrategyInterface $cartTotalDeliveryStrategy,
|
||||
CartWeightDeliveryStrategyInterface $cartWeightDeliveryStrategy,
|
||||
ProductDimensionsDeliveryStrategyInterface $productDimensionsDeliveryStrategy,
|
||||
ProductRestrictionDeliveryInterface $productRestrictionDelivery
|
||||
) {
|
||||
$this->configuration = $configuration;
|
||||
$this->carrierRepository = $carrierRepository;
|
||||
$this->cartTotalDeliveryStrategy = $cartTotalDeliveryStrategy;
|
||||
$this->cartWeightDeliveryStrategy = $cartWeightDeliveryStrategy;
|
||||
$this->productDimensionsDeliveryStrategy = $productDimensionsDeliveryStrategy;
|
||||
$this->productRestrictionDelivery = $productRestrictionDelivery;
|
||||
}
|
||||
|
||||
public function createForCartProduct(
|
||||
DeliveryType $deliveryType,
|
||||
\Cart $cart,
|
||||
\Product $product,
|
||||
Price $unitPrice,
|
||||
float $weight,
|
||||
Quantity $quantity,
|
||||
?int $idShop = null
|
||||
): DeliveryProduct {
|
||||
$totalPrice = $unitPrice->multiply($quantity->getQuantity());
|
||||
$totalWeight = (new Weight($weight))->multiply($quantity->getQuantity());
|
||||
$isDeliveryOptionAvailable = $this->isDeliveryOptionAvailable($product, $deliveryType, $totalPrice, $totalWeight, $cart, $idShop);
|
||||
|
||||
return new DeliveryProduct($deliveryType, $isDeliveryOptionAvailable);
|
||||
}
|
||||
|
||||
public function createForRelatedProduct(
|
||||
DeliveryType $deliveryType,
|
||||
Summary $summary,
|
||||
\Cart $cart,
|
||||
\Product $product,
|
||||
Price $productPrice,
|
||||
Quantity $quantity,
|
||||
?float $freeDeliveryAmount = null,
|
||||
?int $idShop = null
|
||||
): DeliveryRelatedProducts {
|
||||
$basketNewPrice = $this->getCartTotalWithNewProduct($productPrice, $quantity, $this->getCartBasePrice($summary));
|
||||
$basketNewWeight = $this->getCartWeightWithNewProduct($product, $quantity, $cart);
|
||||
$isDeliveryOptionAvailable = $this->isDeliveryOptionAvailable($product, $deliveryType, $basketNewPrice, $basketNewWeight, $cart, $idShop);
|
||||
$isFreeDelivery = $isDeliveryOptionAvailable && $this->isFreeDelivery($freeDeliveryAmount, $basketNewPrice); // if delivery option is not available, free delivery is not possible
|
||||
|
||||
return new DeliveryRelatedProducts(
|
||||
$deliveryType,
|
||||
$isDeliveryOptionAvailable,
|
||||
$isFreeDelivery
|
||||
);
|
||||
}
|
||||
|
||||
private function isDeliveryOptionAvailable(
|
||||
\Product $product,
|
||||
DeliveryType $deliveryType,
|
||||
Price $basketNewPrice,
|
||||
Weight $basketNewWeight,
|
||||
\Cart $cart,
|
||||
?int $idShop = null
|
||||
): bool {
|
||||
$idShop = $idShop ?? (int) $cart->id_shop;
|
||||
$options = $this->configuration->getShippingOptions($deliveryType, (int) $idShop);
|
||||
$referenceId = $options->getCarrierMapping()->getReferenceId();
|
||||
|
||||
if (null === $referenceId || null === $carrier = $this->carrierRepository->findOneByReferenceId($referenceId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$carrier->active) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (false === $this->productRestrictionDelivery->isShippingAvailableBasedOnProductCarrierRestriction($carrier, $product)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (false === $this->productDimensionsDeliveryStrategy->isShippingAvailableBasedOnProductDimensions($carrier, new Dimensions((float) $product->width, (float) $product->height, (float) $product->depth))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (false === $this->cartTotalDeliveryStrategy->isShippingAvailableBasedOnTotalPrice($carrier, $basketNewPrice)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (false === $this->cartWeightDeliveryStrategy->isShippingAvailableBasedOnTotalWeight($carrier, $basketNewWeight)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: pass modified product list
|
||||
return $this->checkModuleRestrictions($carrier, $cart);
|
||||
}
|
||||
|
||||
private function isFreeDelivery(?float $freeDeliveryAmount, Price $basketNewPrice): bool
|
||||
{
|
||||
if (null === $freeDeliveryAmount) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $basketNewPrice->getGross() >= $freeDeliveryAmount;
|
||||
}
|
||||
|
||||
private function getCartTotalWithNewProduct(Price $productPrice, Quantity $quantity, Price $basketBasePrice): Price
|
||||
{
|
||||
$productTotalPrice = $productPrice->multiply($quantity->getQuantity());
|
||||
|
||||
return $basketBasePrice->add($productTotalPrice);
|
||||
}
|
||||
|
||||
private function getCartWeightWithNewProduct(\Product $product, Quantity $quantity, \Cart $cart): Weight
|
||||
{
|
||||
$productWeight = new Weight((float) $product->weight);
|
||||
$defaultCombinationId = (int) \Product::getDefaultAttribute($product->id);
|
||||
$cartWeight = $this->getCartBaseWeight($cart);
|
||||
|
||||
if (0 < $defaultCombinationId) {
|
||||
$combination = new \Combination($defaultCombinationId);
|
||||
$productWeight = $productWeight->add(new Weight((float) $combination->weight));
|
||||
}
|
||||
|
||||
return $cartWeight->add($productWeight->multiply($quantity->getQuantity()));
|
||||
}
|
||||
|
||||
private function getCartBasePrice(Summary $summary): Price
|
||||
{
|
||||
return $summary->getPromoPrice() ?? $summary->getBasePrice();
|
||||
}
|
||||
|
||||
private function getCartBaseWeight(\Cart $cart): Weight
|
||||
{
|
||||
if (!isset($this->cartBaseWeight[$cart->id])) {
|
||||
$this->cartBaseWeight[$cart->id] = new Weight((float) $cart->getTotalWeight());
|
||||
}
|
||||
|
||||
return $this->cartBaseWeight[$cart->id];
|
||||
}
|
||||
|
||||
/**
|
||||
* Carrier modules can disable delivery options by returning false as the shipping cost.
|
||||
*/
|
||||
private function checkModuleRestrictions(\Carrier $carrier, \Cart $cart): bool
|
||||
{
|
||||
if (!$carrier->is_module || !$carrier->shipping_external || $carrier->is_free) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$shippingCost = (\Closure::bind(function () use ($carrier) {
|
||||
$products = $this->getProducts();
|
||||
|
||||
return $this->getPackageShippingCostFromModule($carrier, 10., $products);
|
||||
}, $cart, \Cart::class))();
|
||||
|
||||
return false !== $shippingCost;
|
||||
}
|
||||
}
|
||||
142
modules/inpostizi/src/Builder/Order/OrderEventBuilder.php
Normal file
142
modules/inpostizi/src/Builder/Order/OrderEventBuilder.php
Normal file
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Builder\Order;
|
||||
|
||||
use izi\prestashop\BasketApp\Order\Request\Delivery;
|
||||
use izi\prestashop\BasketApp\Order\Request\OrderEvent;
|
||||
use izi\prestashop\BasketApp\Order\Request\OrderEventData;
|
||||
use izi\prestashop\Common\Order\MerchantOrderStatus;
|
||||
use Psr\Clock\ClockInterface;
|
||||
|
||||
final class OrderEventBuilder implements OrderEventBuilderInterface
|
||||
{
|
||||
/**
|
||||
* @var \Order
|
||||
*/
|
||||
private $order;
|
||||
|
||||
/**
|
||||
* @var ClockInterface
|
||||
*/
|
||||
private $clock;
|
||||
|
||||
/**
|
||||
* @var OrderStatusDescriptionProvider
|
||||
*/
|
||||
private $statusDescriptionProvider;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $eventId;
|
||||
|
||||
/**
|
||||
* @var \DateTimeImmutable|null
|
||||
*/
|
||||
private $eventTime;
|
||||
|
||||
/**
|
||||
* @var MerchantOrderStatus|null
|
||||
*/
|
||||
private $status;
|
||||
|
||||
/**
|
||||
* @var string[]|null
|
||||
*/
|
||||
private $trackingNumbers;
|
||||
|
||||
/**
|
||||
* @var Delivery|null
|
||||
*/
|
||||
private $delivery;
|
||||
|
||||
public function __construct(\Order $order, ClockInterface $clock, OrderStatusDescriptionProvider $orderStatusDescriptionProvider)
|
||||
{
|
||||
$this->order = $order;
|
||||
$this->clock = $clock;
|
||||
$this->statusDescriptionProvider = $orderStatusDescriptionProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function setEventId(string $eventId): OrderEventBuilderInterface
|
||||
{
|
||||
$this->eventId = $eventId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function setEventTime(\DateTimeImmutable $time): OrderEventBuilderInterface
|
||||
{
|
||||
$this->eventTime = $time;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function setOrderStatus(?MerchantOrderStatus $status): OrderEventBuilderInterface
|
||||
{
|
||||
$this->status = $status;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function setTrackingNumbers(?array $numbers): OrderEventBuilderInterface
|
||||
{
|
||||
$this->trackingNumbers = $numbers;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function setDeliveryData(?Delivery $delivery): OrderEventBuilderInterface
|
||||
{
|
||||
$this->delivery = $delivery;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function build(): OrderEvent
|
||||
{
|
||||
$eventData = $this->createEventData();
|
||||
$eventTime = $this->getEventTime();
|
||||
$eventId = $this->getEventId($eventTime);
|
||||
|
||||
return new OrderEvent($eventId, $eventTime, $eventData);
|
||||
}
|
||||
|
||||
private function getEventId(\DateTimeImmutable $eventTime): string
|
||||
{
|
||||
return $this->eventId ?? (string) $eventTime->getTimestamp();
|
||||
}
|
||||
|
||||
private function getEventTime(): \DateTimeImmutable
|
||||
{
|
||||
return $this->eventTime ?? $this->clock->now();
|
||||
}
|
||||
|
||||
private function createEventData(): OrderEventData
|
||||
{
|
||||
$statusDescription = $this->statusDescriptionProvider->getStatus($this->order);
|
||||
|
||||
return new OrderEventData(
|
||||
$this->status,
|
||||
$statusDescription,
|
||||
$this->trackingNumbers,
|
||||
$this->delivery
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace izi\prestashop\Builder\Order;
|
||||
|
||||
use izi\prestashop\ObjectModel\Repository\ObjectRepositoryInterface;
|
||||
use Psr\Clock\ClockInterface;
|
||||
|
||||
final class OrderEventBuilderFactory implements OrderEventBuilderFactoryInterface
|
||||
{
|
||||
/**
|
||||
* @var ObjectRepositoryInterface<\Order>
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var OrderStatusDescriptionProvider
|
||||
*/
|
||||
private $statusDescriptionProvider;
|
||||
|
||||
/**
|
||||
* @var ClockInterface
|
||||
*/
|
||||
private $clock;
|
||||
|
||||
/**
|
||||
* @param ObjectRepositoryInterface<\Order> $repository
|
||||
*/
|
||||
public function __construct(ObjectRepositoryInterface $repository, OrderStatusDescriptionProvider $statusDescriptionProvider, ClockInterface $clock)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
$this->statusDescriptionProvider = $statusDescriptionProvider;
|
||||
$this->clock = $clock;
|
||||
}
|
||||
|
||||
public function create(int $orderId): OrderEventBuilderInterface
|
||||
{
|
||||
if (null === $order = $this->repository->find($orderId)) {
|
||||
throw new \DomainException(sprintf('Order "%s" does not exist.', $orderId));
|
||||
}
|
||||
|
||||
return new OrderEventBuilder($order, $this->clock, $this->statusDescriptionProvider);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user