From 723b6f9b561917ae0a81f535adc998c5c9ca7e87 Mon Sep 17 00:00:00 2001 From: kurozumi Date: Sun, 5 Sep 2021 11:31:44 +0900 Subject: [PATCH 01/21] =?UTF-8?q?PurchaseFlow=E3=81=AEProcessor=E3=82=84Va?= =?UTF-8?q?lidator=E3=81=ABpriority=E3=82=92=E8=A8=AD=E5=AE=9A=E3=81=A7?= =?UTF-8?q?=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/config/eccube/packages/purchaseflow.yaml | 321 ++++++++++-------- .../Compiler/PurchaseFlowPass.php | 53 ++- .../Processor/PaymentValidator.php | 4 +- 3 files changed, 229 insertions(+), 149 deletions(-) diff --git a/app/config/eccube/packages/purchaseflow.yaml b/app/config/eccube/packages/purchaseflow.yaml index a4a621afaed..d3321b57f5f 100644 --- a/app/config/eccube/packages/purchaseflow.yaml +++ b/app/config/eccube/packages/purchaseflow.yaml @@ -1,159 +1,208 @@ services: # Purchase Flow for Cart - eccube.purchase.flow.cart: class: Eccube\Service\PurchaseFlow\PurchaseFlow calls: - - [setFlowType, ['cart']] - - [setItemValidators, ['@eccube.purchase.flow.cart.item_validators']] - - [setItemHolderValidators, ['@eccube.purchase.flow.cart.holder_validators']] - - [setItemPreprocessors, ['@eccube.purchase.flow.cart.item_preprocessors']] - - [setItemHolderPreprocessors, ['@eccube.purchase.flow.cart.holder_preprocessors']] - - [setItemHolderPostValidators, ['@eccube.purchase.flow.cart.holder_post_validators']] - - eccube.purchase.flow.cart.item_validators: - class: Doctrine\Common\Collections\ArrayCollection - arguments: - - # - - '@Eccube\Service\PurchaseFlow\Processor\DeliverySettingValidator' # 配送設定のチェック - - '@Eccube\Service\PurchaseFlow\Processor\ProductStatusValidator' # 商品の公開状態のチェック - - '@Eccube\Service\PurchaseFlow\Processor\PriceChangeValidator' # 商品価格の変更検知 - - '@Eccube\Service\PurchaseFlow\Processor\StockValidator' # 在庫のチェック - - '@Eccube\Service\PurchaseFlow\Processor\SaleLimitValidator' # 販売制限数のチェック - - eccube.purchase.flow.cart.holder_validators: - class: Doctrine\Common\Collections\ArrayCollection - arguments: - - # - - '@Eccube\Service\PurchaseFlow\Processor\EmptyItemsValidator' # 空明細の削除処理 - - eccube.purchase.flow.cart.item_preprocessors: - class: Doctrine\Common\Collections\ArrayCollection - - eccube.purchase.flow.cart.holder_preprocessors: - class: Doctrine\Common\Collections\ArrayCollection - - eccube.purchase.flow.cart.holder_post_validators: - class: Doctrine\Common\Collections\ArrayCollection - arguments: - - # - - '@Eccube\Service\PurchaseFlow\Processor\PaymentValidator' # 使用できない支払い方法が含まれていないかどうか - - '@Eccube\Service\PurchaseFlow\Processor\PaymentTotalLimitValidator' # 支払金額の上限チェック - - '@Eccube\Service\PurchaseFlow\Processor\PaymentTotalNegativeValidator' # 支払金額のマイナスチェック + - [ setFlowType, [ 'cart' ] ] # Purchase Flow for Shopping eccube.purchase.flow.shopping: class: Eccube\Service\PurchaseFlow\PurchaseFlow calls: - - [setFlowType, ['shopping']] - - [setItemValidators, ['@eccube.purchase.flow.shopping.item_validators']] - - [setItemHolderValidators, ['@eccube.purchase.flow.shopping.holder_validators']] - - [setItemHolderPreprocessors, ['@eccube.purchase.flow.shopping.holder_preprocessors']] - - [setDiscountProcessors, ['@eccube.purchase.flow.shopping.discount_processors']] - - [setItemHolderPostValidators, ['@eccube.purchase.flow.shopping.holder_post_validators']] - - [setPurchaseProcessors, ['@eccube.purchase.flow.shopping.purchase']] - - eccube.purchase.flow.shopping.item_validators: - class: Doctrine\Common\Collections\ArrayCollection - arguments: - - # - - '@Eccube\Service\PurchaseFlow\Processor\DeliverySettingValidator' - - '@Eccube\Service\PurchaseFlow\Processor\ProductStatusValidator' - - '@Eccube\Service\PurchaseFlow\Processor\PriceChangeValidator' - - eccube.purchase.flow.shopping.holder_validators: - class: Doctrine\Common\Collections\ArrayCollection - arguments: - - # - - '@Eccube\Service\PurchaseFlow\Processor\StockMultipleValidator' - - '@Eccube\Service\PurchaseFlow\Processor\SaleLimitMultipleValidator' - - '@Eccube\Service\PurchaseFlow\Processor\EmptyItemsValidator' # 空明細の削除処理 - - eccube.purchase.flow.shopping.holder_preprocessors: - class: Doctrine\Common\Collections\ArrayCollection - arguments: - - # - - '@Eccube\Service\PurchaseFlow\Processor\TaxProcessor' # 税額の計算(商品明細に対して税額計算) - - '@Eccube\Service\PurchaseFlow\Processor\OrderNoProcessor' - - '@Eccube\Service\PurchaseFlow\Processor\DeliveryFeePreprocessor' - - '@Eccube\Service\PurchaseFlow\Processor\DeliveryFeeFreeByShippingPreprocessor' - - '@Eccube\Service\PurchaseFlow\Processor\PaymentChargePreprocessor' - - '@Eccube\Service\PurchaseFlow\Processor\TaxProcessor' # 税額の計算(送料明細・手数料明細に対して税額を計算) - - eccube.purchase.flow.shopping.discount_processors: - class: Doctrine\Common\Collections\ArrayCollection - arguments: - - # - - '@Eccube\Service\PurchaseFlow\Processor\PointProcessor' # ポイント明細の追加 - - eccube.purchase.flow.shopping.holder_post_validators: - class: Doctrine\Common\Collections\ArrayCollection - arguments: - - # - - '@Eccube\Service\PurchaseFlow\Processor\AddPointProcessor' # 加算ポイントの計算 - - '@Eccube\Service\PurchaseFlow\Processor\PaymentTotalLimitValidator' - - '@Eccube\Service\PurchaseFlow\Processor\PaymentTotalNegativeValidator' - - '@Eccube\Service\PurchaseFlow\Processor\PaymentChargeChangeValidator' # 手数料の変更検知 - - '@Eccube\Service\PurchaseFlow\Processor\DeliveryFeeChangeValidator' # 送料の変更検知 - - eccube.purchase.flow.shopping.purchase: - class: Doctrine\Common\Collections\ArrayCollection - arguments: - - # - - '@Eccube\Service\PurchaseFlow\Processor\PreOrderIdValidator' - - '@Eccube\Service\PurchaseFlow\Processor\PointProcessor' - - '@Eccube\Service\PurchaseFlow\Processor\StockReduceProcessor' - - '@Eccube\Service\PurchaseFlow\Processor\CustomerPurchaseInfoProcessor' - - '@Eccube\Service\PurchaseFlow\Processor\OrderUpdateProcessor' + - [ setFlowType, [ 'shopping' ] ] # Purchase Flow for Order - eccube.purchase.flow.order: class: Eccube\Service\PurchaseFlow\PurchaseFlow calls: - - [setFlowType, ['order']] - - [setItemValidators, ['@eccube.purchase.flow.order.item_validators']] - - [setItemHolderValidators, ['@eccube.purchase.flow.order.holder_validators']] - - [setItemHolderPreprocessors, ['@eccube.purchase.flow.order.holder_preprocessors']] - - [setDiscountProcessors, ['@eccube.purchase.flow.order.discount_processors']] - - [setItemHolderPostValidators, ['@eccube.purchase.flow.order.holder_post_validators']] - - [setPurchaseProcessors, ['@eccube.purchase.flow.order.purchase']] - - eccube.purchase.flow.order.item_validators: - class: Doctrine\Common\Collections\ArrayCollection - - eccube.purchase.flow.order.holder_validators: - class: Doctrine\Common\Collections\ArrayCollection - arguments: - - # - - '@Eccube\Service\PurchaseFlow\Processor\StockDiffProcessor' - - '@Eccube\Service\PurchaseFlow\Processor\PointDiffProcessor' + - [ setFlowType, [ 'order' ] ] - eccube.purchase.flow.order.holder_preprocessors: - class: Doctrine\Common\Collections\ArrayCollection - arguments: - - # - - '@Eccube\Service\PurchaseFlow\Processor\TaxProcessor' - eccube.purchase.flow.order.discount_processors: - class: Doctrine\Common\Collections\ArrayCollection + # addItemValidator + eccube.purchase.flow.item.validator.delivery.setting.validator: # 配送設定のチェック + class: Eccube\Service\PurchaseFlow\Processor\DeliverySettingValidator arguments: - - # - - '@Eccube\Service\PurchaseFlow\Processor\PointProcessor' # ポイント明細の追加 - - eccube.purchase.flow.order.holder_post_validators: - class: Doctrine\Common\Collections\ArrayCollection + - '@Eccube\Repository\DeliveryRepository' + tags: + - { name: eccube.item.validator, flow_type: cart, priority: 100 } + - { name: eccube.item.validator, flow_type: shopping, priority: 100 } + + eccube.purchase.flow.item.validator.product.status.validator: # 商品の公開状態のチェック + class: Eccube\Service\PurchaseFlow\Processor\ProductStatusValidator + tags: + - { name: eccube.item.validator, flow_type: cart, priority: 90 } + - { name: eccube.item.validator, flow_type: shopping, priority: 90 } + + eccube.purchase.flow.item.validator.price.change.validator: # 商品価格の変更検知 + class: Eccube\Service\PurchaseFlow\Processor\PriceChangeValidator + tags: + - { name: eccube.item.validator, flow_type: cart, priority: 80 } + - { name: eccube.item.validator, flow_type: shopping, priority: 80 } + + eccube.purchase.flow.item.validator.stock.validator: # 在庫のチェック + class: Eccube\Service\PurchaseFlow\Processor\StockValidator + tags: + - { name: eccube.item.validator, flow_type: cart, priority: 70 } + + eccube.purchase.flow.item.validator.sale.limit.validator: # 販売制限数のチェック + class: Eccube\Service\PurchaseFlow\Processor\SaleLimitValidator + tags: + - { name: eccube.item.validator, flow_type: cart, priority: 60 } + + # addItemHolderValidator + eccube.purchase.flow.item.holder.validator.stock.multiple.validator: + class: Eccube\Service\PurchaseFlow\Processor\StockMultipleValidator + tags: + - { name: eccube.item.holder.validator, flow_type: shopping, priority: 100 } + + eccube.purchase.flow.item.holder.validator.sale.limit.multiple.validator: + class: Eccube\Service\PurchaseFlow\Processor\SaleLimitMultipleValidator + tags: + - { name: eccube.item.holder.validator, flow_type: shopping, priority: 90 } + + eccube.purchase.flow.item.holder.validator.empty.items.validator: # 空明細の削除処理 + class: Eccube\Service\PurchaseFlow\Processor\EmptyItemsValidator + arguments: + - '@doctrine.orm.default_entity_manager' + tags: + - { name: eccube.item.holder.validator, flow_type: cart, priority: 100 } + - { name: eccube.item.holder.validator, flow_type: shopping, priority: 80 } + + eccube.purchase.flow.item.holder.validator.stock.diff.processor: + class: Eccube\Service\PurchaseFlow\Processor\StockDiffProcessor + tags: + - { name: eccube.item.holder.validator, flow_type: order, priority: 100 } + + eccube.purchase.flow.item.holder.validator.point.diff.processor: + class: Eccube\Service\PurchaseFlow\Processor\PointDiffProcessor + tags: + - { name: eccube.item.holder.validator, flow_type: order, priority: 90 } + + # addItemPreprocessor + + # addItemHolderPreprocessor + eccube.purchase.flow.item.holder.preprocessor.tax.processor.before: # 税額の計算(商品明細に対して税額計算) + class: Eccube\Service\PurchaseFlow\Processor\TaxProcessor + tags: + - { name: eccube.item.holder.preprocessor, flow_type: shopping, priority: 100 } + - { name: eccube.item.holder.preprocessor, flow_type: order, priority: 100 } + + eccube.purchase.flow.item.holder.preprocessor.order.no.processor: + class: Eccube\Service\PurchaseFlow\Processor\OrderNoProcessor + tags: + - { name: eccube.item.holder.preprocessor, flow_type: shopping, priority: 90 } + + eccube.purchase.flow.item.holder.preprocessor.delivery.fee.preprocessor: + class: Eccube\Service\PurchaseFlow\Processor\DeliveryFeePreprocessor + tags: + - { name: eccube.item.holder.preprocessor, flow_type: shopping, priority: 80 } + + eccube.purchase.flow.item.holder.preprocessor.delivery.fee.free.by.shipping.preprocessor: + class: Eccube\Service\PurchaseFlow\Processor\DeliveryFeeFreeByShippingPreprocessor + tags: + - { name: eccube.item.holder.preprocessor, flow_type: shopping, priority: 70 } + + eccube.purchase.flow.item.holder.preprocessor.pyament.charge.preprocessor: + class: Eccube\Service\PurchaseFlow\Processor\PaymentChargePreprocessor + tags: + - { name: eccube.item.holder.preprocessor, flow_type: shopping, priority: 50 } + + eccube.purchase.flow.item.holder.preprocessor.tax.processor.after: # 税額の計算(商品明細に対して税額計算) + class: Eccube\Service\PurchaseFlow\Processor\TaxProcessor + tags: + - { name: eccube.item.holder.preprocessor, flow_type: shopping, priority: 40 } + + # addDiscountProcessor + eccube.purchase.flow.discount.processor.point.processor: + class: Eccube\Service\PurchaseFlow\Processor\PointProcessor + arguments: + - '@doctrine.orm.default_entity_manager' + - '@Eccube\Service\PointHelper' + tags: + - { name: eccube.discount.processor, flow_type: shopping, priority: 100 } + - { name: eccube.discount.processor, flow_type: order, priority: 100 } + + # addItemHolderPostValidator + eccube.purchase.flow.item.holder.post.validator.payment.validator: # 使用できない支払い方法が含まれていないかどうか + class: Eccube\Service\PurchaseFlow\Processor\PaymentValidator arguments: - - # - - '@Eccube\Service\PurchaseFlow\Processor\AddPointProcessor' # 加算ポイントの計算 - - '@Eccube\Service\PurchaseFlow\Processor\PaymentTotalLimitValidator' - - '@Eccube\Service\PurchaseFlow\Processor\PaymentTotalNegativeValidator' # 支払金額のマイナスチェック + - '@Eccube\Repository\DeliveryRepository' + tags: + - { name: eccube.item.holder.post.validator, flow_type: cart, priority: 100 } + + eccube.purchase.flow.item.holder.post.validator.add.point.processor: + class: Eccube\Service\PurchaseFlow\Processor\AddPointProcessor + tags: + - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 100 } + - { name: eccube.item.holder.post.validator, flow_type: order, priority: 100 } + + eccube.purchase.flow.item.holder.post.validator.payment.total.limit.validator: # 支払金額の上限チェック + class: Eccube\Service\PurchaseFlow\Processor\PaymentTotalLimitValidator + arguments: + - '@Eccube\Common\EccubeConfig' + tags: + - { name: eccube.item.holder.post.validator, flow_type: cart, priority: 90 } + - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 90 } + - { name: eccube.item.holder.post.validator, flow_type: order, priority: 90 } + + eccube.purchase.flow.item.holder.post.validator.total.negative.validator: # 支払金額のマイナスチェック + class: Eccube\Service\PurchaseFlow\Processor\PaymentTotalNegativeValidator + tags: + - { name: eccube.item.holder.post.validator, flow_type: cart, priority: 80 } + - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 80 } + - { name: eccube.item.holder.post.validator, flow_type: order, priority: 80 } + + eccube.purchase.flow.item.holder.post.validator.payment.charge.change.validator: # 手数料の変更検知 + class: Eccube\Service\PurchaseFlow\Processor\PaymentChargeChangeValidator + tags: + - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 70 } + + eccube.purcahse.flow.item.holder.post.validator.delivery.fee.change.validator: # 送料の変更検知 + class: Eccube\Service\PurchaseFlow\Processor\DeliveryFeeChangeValidator + tags: + - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 60 } + + # addPurchaseProcessor + eccybe.purchase.flow.purchase.processor.pre.order.id.validator: + class: Eccube\Service\PurchaseFlow\Processor\PreOrderIdValidator + arguments: + - '@Eccube\Service\CartService' + tags: + - { name: eccube.purchase.processor, flow_type: shopping, priority: 100 } + eccube.purchase.flow.purchase.processor.point.processor: + class: Eccube\Service\PurchaseFlow\Processor\PointProcessor + arguments: + - '@doctrine.orm.default_entity_manager' + - '@Eccube\Service\PointHelper' + tags: + - { name: eccube.purchase.processor, flow_type: shopping, priority: 90 } - eccube.purchase.flow.order.purchase: - class: Doctrine\Common\Collections\ArrayCollection + eccube.purchase.flow.purchase.processor.stock.reduce.processor: + class: Eccube\Service\PurchaseFlow\Processor\StockReduceProcessor arguments: - - # - - '@Eccube\Service\PurchaseFlow\Processor\StockDiffProcessor' - - '@Eccube\Service\PurchaseFlow\Processor\PointDiffProcessor' \ No newline at end of file + - '@Eccube\Repository\ProductStockRepository' + - '@doctrine.orm.default_entity_manager' + tags: + - { name: eccube.purchase.processor, flow_type: shopping, priority: 90 } + + eccube.purchase.flow.purchase.processor.customer.purchase.info.processor: + class: Eccube\Service\PurchaseFlow\Processor\CustomerPurchaseInfoProcessor + tags: + - { name: eccube.purchase.processor, flow_type: shopping, priority: 80 } + + eccube.purchase.flow.purchase.processor.order.update.processor: + class: Eccube\Service\PurchaseFlow\Processor\OrderUpdateProcessor + tags: + - { name: eccube.purchase.processor, flow_type: shopping, priority: 70 } + + eccube.purchase.flow.purchase.processor.stock.diff.processor: + class: Eccube\Service\PurchaseFlow\Processor\StockDiffProcessor + tags: + - { name: eccube.purchase.processor, flow_type: order, priority: 100 } + + eccube.purchase.flow.purchase.processor.point.diff.processor: + class: Eccube\Service\PurchaseFlow\Processor\PointDiffProcessor + tags: + - { name: eccube.purchase.processor, flow_type: order, priority: 90 } diff --git a/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php b/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php index 57fa472d45d..84dc1a475b7 100644 --- a/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php +++ b/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php @@ -18,12 +18,16 @@ use Eccube\Annotation\CartFlow; use Eccube\Annotation\OrderFlow; use Eccube\Annotation\ShoppingFlow; +use Eccube\Service\PurchaseFlow\PurchaseContext; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; class PurchaseFlowPass implements CompilerPassInterface { + use PriorityTaggedServiceTrait; + const ITEM_PREPROCESSOR_TAG = 'eccube.item.preprocessor'; const ITEM_VALIDATOR_TAG = 'eccube.item.validator'; const ITEM_HOLDER_PREPROCESSOR_TAG = 'eccube.item.holder.preprocessor'; @@ -34,26 +38,37 @@ class PurchaseFlowPass implements CompilerPassInterface public function process(ContainerBuilder $container) { + $flowTypes = [ + PurchaseContext::CART_FLOW => $container->findDefinition('eccube.purchase.flow.cart'), + PurchaseContext::SHOPPING_FLOW => $container->findDefinition('eccube.purchase.flow.shopping'), + PurchaseContext::ORDER_FLOW => $container->findDefinition('eccube.purchase.flow.order') + ]; + + foreach ($this->getProcessorTags() as $tag => $methodName) { + foreach ($this->findAndSortTaggedServices($tag, $container) as $id) { + $definition = $container->findDefinition($id); + foreach ($definition->getTag($tag) as $attributes) { + if (isset($attributes['flow_type'])) { + foreach ($flowTypes as $flowType => $purchaseFlowDef) { + if ($flowType === $attributes['flow_type']) { + $purchaseFlowDef->addMethodCall($methodName, [new Reference($id)]); + } + } + } + } + } + } + $flowDefs = [ CartFlow::class => $container->getDefinition('eccube.purchase.flow.cart'), ShoppingFlow::class => $container->getDefinition('eccube.purchase.flow.shopping'), OrderFlow::class => $container->getDefinition('eccube.purchase.flow.order'), ]; - $processorTags = [ - self::ITEM_PREPROCESSOR_TAG => 'addItemPreprocessor', - self::ITEM_VALIDATOR_TAG => 'addItemValidator', - self::ITEM_HOLDER_PREPROCESSOR_TAG => 'addItemHolderPreprocessor', - self::ITEM_HOLDER_VALIDATOR_TAG => 'addItemHolderValidator', - self::ITEM_HOLDER_POST_VALIDATOR_TAG => 'addItemHolderPostValidator', - self::DISCOUNT_PROCESSOR_TAG => 'addDiscountProcessor', - self::PURCHASE_PROCESSOR_TAG => 'addPurchaseProcessor', - ]; - AnnotationRegistry::registerAutoloadNamespace('Eccube\Annotation', __DIR__.'/../../../../src'); $reader = new AnnotationReader(); - foreach ($processorTags as $tag => $methodName) { + foreach ($this->getProcessorTags() as $tag => $methodName) { $ids = $container->findTaggedServiceIds($tag); foreach ($ids as $id => $tags) { $def = $container->getDefinition($id); @@ -67,4 +82,20 @@ public function process(ContainerBuilder $container) } } } + + /** + * @return string[] + */ + public function getProcessorTags(): array + { + return [ + self::ITEM_PREPROCESSOR_TAG => 'addItemPreprocessor', + self::ITEM_VALIDATOR_TAG => 'addItemValidator', + self::ITEM_HOLDER_PREPROCESSOR_TAG => 'addItemHolderPreprocessor', + self::ITEM_HOLDER_VALIDATOR_TAG => 'addItemHolderValidator', + self::ITEM_HOLDER_POST_VALIDATOR_TAG => 'addItemHolderPostValidator', + self::DISCOUNT_PROCESSOR_TAG => 'addDiscountProcessor', + self::PURCHASE_PROCESSOR_TAG => 'addPurchaseProcessor', + ]; + } } diff --git a/src/Eccube/Service/PurchaseFlow/Processor/PaymentValidator.php b/src/Eccube/Service/PurchaseFlow/Processor/PaymentValidator.php index e598ec08aa7..62a0f06b9ee 100644 --- a/src/Eccube/Service/PurchaseFlow/Processor/PaymentValidator.php +++ b/src/Eccube/Service/PurchaseFlow/Processor/PaymentValidator.php @@ -19,13 +19,13 @@ use Eccube\Entity\Master\SaleType; use Eccube\Entity\Payment; use Eccube\Repository\DeliveryRepository; -use Eccube\Service\PurchaseFlow\ItemHolderValidator; +use Eccube\Service\PurchaseFlow\ItemHolderPostValidator; use Eccube\Service\PurchaseFlow\PurchaseContext; /** * 支払い方法が一致しない明細がないかどうか. */ -class PaymentValidator extends ItemHolderValidator +class PaymentValidator extends ItemHolderPostValidator { /** * @var DeliveryRepository From 5cc59620acd717225df2af10035fffe86e24a383 Mon Sep 17 00:00:00 2001 From: kurozumi Date: Sun, 5 Sep 2021 11:49:08 +0900 Subject: [PATCH 02/21] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=81=A7?= =?UTF-8?q?=E7=99=BA=E7=94=9F=E3=81=99=E3=82=8B=E3=82=A8=E3=83=A9=E3=83=BC?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/config/eccube/packages/purchaseflow.yaml | 40 ++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/app/config/eccube/packages/purchaseflow.yaml b/app/config/eccube/packages/purchaseflow.yaml index d3321b57f5f..b48a353231b 100644 --- a/app/config/eccube/packages/purchaseflow.yaml +++ b/app/config/eccube/packages/purchaseflow.yaml @@ -53,11 +53,15 @@ services: # addItemHolderValidator eccube.purchase.flow.item.holder.validator.stock.multiple.validator: class: Eccube\Service\PurchaseFlow\Processor\StockMultipleValidator + arguments: + - '@Eccube\Repository\ProductClassRepository' tags: - { name: eccube.item.holder.validator, flow_type: shopping, priority: 100 } eccube.purchase.flow.item.holder.validator.sale.limit.multiple.validator: class: Eccube\Service\PurchaseFlow\Processor\SaleLimitMultipleValidator + arguments: + - '@Eccube\Repository\ProductClassRepository' tags: - { name: eccube.item.holder.validator, flow_type: shopping, priority: 90 } @@ -71,11 +75,16 @@ services: eccube.purchase.flow.item.holder.validator.stock.diff.processor: class: Eccube\Service\PurchaseFlow\Processor\StockDiffProcessor + arguments: + - '@Eccube\Repository\ProductClassRepository' tags: - { name: eccube.item.holder.validator, flow_type: order, priority: 100 } eccube.purchase.flow.item.holder.validator.point.diff.processor: class: Eccube\Service\PurchaseFlow\Processor\PointDiffProcessor + arguments: + - '@doctrine.orm.default_entity_manager' + - '@Eccube\Service\PointHelper' tags: - { name: eccube.item.holder.validator, flow_type: order, priority: 90 } @@ -84,32 +93,54 @@ services: # addItemHolderPreprocessor eccube.purchase.flow.item.holder.preprocessor.tax.processor.before: # 税額の計算(商品明細に対して税額計算) class: Eccube\Service\PurchaseFlow\Processor\TaxProcessor + arguments: + - '@doctrine.orm.default_entity_manager' + - '@Eccube\Repository\TaxRuleRepository' + - '@Eccube\Service\TaxRuleService' tags: - { name: eccube.item.holder.preprocessor, flow_type: shopping, priority: 100 } - { name: eccube.item.holder.preprocessor, flow_type: order, priority: 100 } eccube.purchase.flow.item.holder.preprocessor.order.no.processor: class: Eccube\Service\PurchaseFlow\Processor\OrderNoProcessor + arguments: + - '@Eccube\Common\EccubeConfig' + - '@Eccube\Repository\OrderRepository' tags: - { name: eccube.item.holder.preprocessor, flow_type: shopping, priority: 90 } eccube.purchase.flow.item.holder.preprocessor.delivery.fee.preprocessor: class: Eccube\Service\PurchaseFlow\Processor\DeliveryFeePreprocessor + arguments: + - '@Eccube\Repository\BaseInfoRepository' + - '@doctrine.orm.default_entity_manager' + - '@Eccube\Repository\TaxRuleRepository' + - '@Eccube\Repository\DeliveryFeeRepository' tags: - { name: eccube.item.holder.preprocessor, flow_type: shopping, priority: 80 } eccube.purchase.flow.item.holder.preprocessor.delivery.fee.free.by.shipping.preprocessor: class: Eccube\Service\PurchaseFlow\Processor\DeliveryFeeFreeByShippingPreprocessor + arguments: + - '@Eccube\Repository\BaseInfoRepository' tags: - { name: eccube.item.holder.preprocessor, flow_type: shopping, priority: 70 } eccube.purchase.flow.item.holder.preprocessor.pyament.charge.preprocessor: class: Eccube\Service\PurchaseFlow\Processor\PaymentChargePreprocessor + arguments: + - '@Eccube\Repository\Master\OrderItemTypeRepository' + - '@Eccube\Repository\Master\TaxDisplayTypeRepository' + - '@Eccube\Repository\Master\TaxTypeRepository' tags: - { name: eccube.item.holder.preprocessor, flow_type: shopping, priority: 50 } eccube.purchase.flow.item.holder.preprocessor.tax.processor.after: # 税額の計算(商品明細に対して税額計算) class: Eccube\Service\PurchaseFlow\Processor\TaxProcessor + arguments: + - '@doctrine.orm.default_entity_manager' + - '@Eccube\Repository\TaxRuleRepository' + - '@Eccube\Service\TaxRuleService' tags: - { name: eccube.item.holder.preprocessor, flow_type: shopping, priority: 40 } @@ -133,6 +164,8 @@ services: eccube.purchase.flow.item.holder.post.validator.add.point.processor: class: Eccube\Service\PurchaseFlow\Processor\AddPointProcessor + arguments: + - '@Eccube\Repository\BaseInfoRepository' tags: - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 100 } - { name: eccube.item.holder.post.validator, flow_type: order, priority: 100 } @@ -194,15 +227,22 @@ services: eccube.purchase.flow.purchase.processor.order.update.processor: class: Eccube\Service\PurchaseFlow\Processor\OrderUpdateProcessor + arguments: + - '@Eccube\Repository\Master\OrderStatusRepository' tags: - { name: eccube.purchase.processor, flow_type: shopping, priority: 70 } eccube.purchase.flow.purchase.processor.stock.diff.processor: class: Eccube\Service\PurchaseFlow\Processor\StockDiffProcessor + arguments: + - '@Eccube\Repository\ProductClassRepository' tags: - { name: eccube.purchase.processor, flow_type: order, priority: 100 } eccube.purchase.flow.purchase.processor.point.diff.processor: class: Eccube\Service\PurchaseFlow\Processor\PointDiffProcessor + arguments: + - '@doctrine.orm.default_entity_manager' + - '@Eccube\Service\PointHelper' tags: - { name: eccube.purchase.processor, flow_type: order, priority: 90 } From 9eb4b04b1c54b5647745e508b7698c695a6571a0 Mon Sep 17 00:00:00 2001 From: kurozumi Date: Sun, 5 Sep 2021 12:29:19 +0900 Subject: [PATCH 03/21] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=81=A7?= =?UTF-8?q?=E7=99=BA=E7=94=9F=E3=81=99=E3=82=8B=E3=82=A8=E3=83=A9=E3=83=BC?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php b/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php index 84dc1a475b7..a5ad6a0044f 100644 --- a/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php +++ b/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php @@ -52,6 +52,7 @@ public function process(ContainerBuilder $container) foreach ($flowTypes as $flowType => $purchaseFlowDef) { if ($flowType === $attributes['flow_type']) { $purchaseFlowDef->addMethodCall($methodName, [new Reference($id)]); + $purchaseFlowDef->setPublic(true); } } } From 1d6cfec44da55dd2b1460660fa8e751aa82d0a90 Mon Sep 17 00:00:00 2001 From: kurozumi Date: Sun, 5 Sep 2021 12:43:11 +0900 Subject: [PATCH 04/21] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=81=A7?= =?UTF-8?q?=E7=99=BA=E7=94=9F=E3=81=99=E3=82=8B=E3=82=A8=E3=83=A9=E3=83=BC?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/config/eccube/services_test.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/app/config/eccube/services_test.yaml b/app/config/eccube/services_test.yaml index 07b6cf62b45..5dc7fccba68 100644 --- a/app/config/eccube/services_test.yaml +++ b/app/config/eccube/services_test.yaml @@ -42,6 +42,27 @@ services: Eccube\Service\PurchaseFlow\Processor\AddPointProcessor: autowire: true public: true + Eccube\Service\PurchaseFlow\Processor\DeliverySettingValidator: + autowire: true + public: true + Eccube\Service\PurchaseFlow\Processor\EmptyItemsValidator: + autowire: true + public: true + Eccube\Service\PurchaseFlow\Processor\PaymentTotalLimitValidator: + autowire: true + public: true + Eccube\Service\PurchaseFlow\Processor\PointDiffProcessor: + autowire: true + public: true + Eccube\Service\PurchaseFlow\Processor\PriceChangeValidator: + autowire: true + public: true + Eccube\Service\PurchaseFlow\Processor\ProductStatusValidator: + autowire: true + public: true + Eccube\Service\PurchaseFlow\Processor\StockDiffProcessor: + autowire: true + public: true Eccube\Service\Composer\ComposerApiService: autowire: true public: true From 2aa07cb22cd1dd345dcb479ce09f77214466670a Mon Sep 17 00:00:00 2001 From: kurozumi Date: Sun, 5 Sep 2021 13:36:16 +0900 Subject: [PATCH 05/21] =?UTF-8?q?=E8=BB=BD=E5=BE=AE=E3=81=AA=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DependencyInjection/Compiler/PurchaseFlowPass.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php b/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php index a5ad6a0044f..ea73508bf69 100644 --- a/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php +++ b/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php @@ -52,7 +52,6 @@ public function process(ContainerBuilder $container) foreach ($flowTypes as $flowType => $purchaseFlowDef) { if ($flowType === $attributes['flow_type']) { $purchaseFlowDef->addMethodCall($methodName, [new Reference($id)]); - $purchaseFlowDef->setPublic(true); } } } @@ -61,9 +60,9 @@ public function process(ContainerBuilder $container) } $flowDefs = [ - CartFlow::class => $container->getDefinition('eccube.purchase.flow.cart'), - ShoppingFlow::class => $container->getDefinition('eccube.purchase.flow.shopping'), - OrderFlow::class => $container->getDefinition('eccube.purchase.flow.order'), + CartFlow::class => $container->findDefinition('eccube.purchase.flow.cart'), + ShoppingFlow::class => $container->findDefinition('eccube.purchase.flow.shopping'), + OrderFlow::class => $container->findDefinition('eccube.purchase.flow.order'), ]; AnnotationRegistry::registerAutoloadNamespace('Eccube\Annotation', __DIR__.'/../../../../src'); From 30740ea45e79471e378177d223b7f6ac627c28f2 Mon Sep 17 00:00:00 2001 From: kurozumi Date: Tue, 7 Sep 2021 22:01:13 +0900 Subject: [PATCH 06/21] =?UTF-8?q?GitHub=20Actions=E3=82=92=E5=86=8D?= =?UTF-8?q?=E5=AE=9F=E8=A1=8C=E3=81=95=E3=81=9B=E3=82=8B=E3=81=9F=E3=82=81?= =?UTF-8?q?=E8=BB=BD=E5=BE=AE=E3=81=AA=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php b/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php index ea73508bf69..2077315f62b 100644 --- a/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php +++ b/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php @@ -46,8 +46,8 @@ public function process(ContainerBuilder $container) foreach ($this->getProcessorTags() as $tag => $methodName) { foreach ($this->findAndSortTaggedServices($tag, $container) as $id) { - $definition = $container->findDefinition($id); - foreach ($definition->getTag($tag) as $attributes) { + $def = $container->findDefinition($id); + foreach ($def->getTag($tag) as $attributes) { if (isset($attributes['flow_type'])) { foreach ($flowTypes as $flowType => $purchaseFlowDef) { if ($flowType === $attributes['flow_type']) { From 5f3ccf7f40edf7d81e642e1ec4ea27c9172e2d03 Mon Sep 17 00:00:00 2001 From: kurozumi Date: Wed, 21 Feb 2024 15:47:24 +0900 Subject: [PATCH 07/21] =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/config/eccube/packages/purchaseflow.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/config/eccube/packages/purchaseflow.yaml b/app/config/eccube/packages/purchaseflow.yaml index b48a353231b..03434958e3c 100644 --- a/app/config/eccube/packages/purchaseflow.yaml +++ b/app/config/eccube/packages/purchaseflow.yaml @@ -97,6 +97,7 @@ services: - '@doctrine.orm.default_entity_manager' - '@Eccube\Repository\TaxRuleRepository' - '@Eccube\Service\TaxRuleService' + - '@Eccube\Service\OrderHelper' tags: - { name: eccube.item.holder.preprocessor, flow_type: shopping, priority: 100 } - { name: eccube.item.holder.preprocessor, flow_type: order, priority: 100 } @@ -141,6 +142,7 @@ services: - '@doctrine.orm.default_entity_manager' - '@Eccube\Repository\TaxRuleRepository' - '@Eccube\Service\TaxRuleService' + - '@Eccube\Service\OrderHelper' tags: - { name: eccube.item.holder.preprocessor, flow_type: shopping, priority: 40 } From dfe82a10973c5996b83055eb1e2c4c97ca544a0c Mon Sep 17 00:00:00 2001 From: kurozumi Date: Wed, 21 Feb 2024 18:38:19 +0900 Subject: [PATCH 08/21] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E7=94=A8?= =?UTF-8?q?=E3=81=AB=E4=B8=80=E9=83=A8=E3=81=AE=E3=83=97=E3=83=AD=E3=82=BB?= =?UTF-8?q?=E3=83=83=E3=82=B5=E3=83=BC=E3=82=92public=E3=81=AB=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/config/eccube/services_test.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/config/eccube/services_test.yaml b/app/config/eccube/services_test.yaml index 5dc7fccba68..eb10142e0b0 100644 --- a/app/config/eccube/services_test.yaml +++ b/app/config/eccube/services_test.yaml @@ -63,6 +63,15 @@ services: Eccube\Service\PurchaseFlow\Processor\StockDiffProcessor: autowire: true public: true + Eccube\Service\PurchaseFlow\Processor\ClassCategoryValidator: + autowire: true + public: true + Eccube\Service\PurchaseFlow\Processor\PaymentTotalNegativeValidator: + autowire: true + public: true + Eccube\Service\PurchaseFlow\Processor\PointRateProcessor: + autowire: true + public: true Eccube\Service\Composer\ComposerApiService: autowire: true public: true From 3b34131e8bfb97942e4dae809cba20f6bda13dc5 Mon Sep 17 00:00:00 2001 From: kurozumi Date: Wed, 21 Feb 2024 20:42:09 +0900 Subject: [PATCH 09/21] =?UTF-8?q?=E5=88=87=E3=82=8A=E5=87=BA=E3=81=95?= =?UTF-8?q?=E3=82=8C=E3=81=A6=E3=81=84=E3=82=8B=E3=83=97=E3=83=AD=E3=82=BB?= =?UTF-8?q?=E3=83=83=E3=82=B5=E3=83=BC=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/config/eccube/packages/purchaseflow.yaml | 47 +++++++++++++------ .../Compiler/PurchaseFlowPass.php | 6 +-- 2 files changed, 36 insertions(+), 17 deletions(-) diff --git a/app/config/eccube/packages/purchaseflow.yaml b/app/config/eccube/packages/purchaseflow.yaml index 03434958e3c..a6a6b8097e9 100644 --- a/app/config/eccube/packages/purchaseflow.yaml +++ b/app/config/eccube/packages/purchaseflow.yaml @@ -50,6 +50,12 @@ services: tags: - { name: eccube.item.validator, flow_type: cart, priority: 60 } + eccube.purchase.flow.item.validator.class_category.validator: # 販売制限数のチェック + class: Eccube\Service\PurchaseFlow\Processor\ClassCategoryValidator + tags: + - { name: eccube.item.validator, flow_type: cart, priority: 50 } + - { name: eccube.item.validator, flow_type: shopping, priority: 50 } + # addItemHolderValidator eccube.purchase.flow.item.holder.validator.stock.multiple.validator: class: Eccube\Service\PurchaseFlow\Processor\StockMultipleValidator @@ -136,7 +142,7 @@ services: tags: - { name: eccube.item.holder.preprocessor, flow_type: shopping, priority: 50 } - eccube.purchase.flow.item.holder.preprocessor.tax.processor.after: # 税額の計算(商品明細に対して税額計算) + eccube.purchase.flow.item.holder.preprocessor.tax.processor.after: # 税額の計算(送料明細・手数料明細に対して税額を計算) class: Eccube\Service\PurchaseFlow\Processor\TaxProcessor arguments: - '@doctrine.orm.default_entity_manager' @@ -157,46 +163,59 @@ services: - { name: eccube.discount.processor, flow_type: order, priority: 100 } # addItemHolderPostValidator - eccube.purchase.flow.item.holder.post.validator.payment.validator: # 使用できない支払い方法が含まれていないかどうか - class: Eccube\Service\PurchaseFlow\Processor\PaymentValidator + eccube.purchase.flow.item.holder.post.validator.point.rate.validator: # 明細にポイント付与率を設定する + class: Eccube\Service\PurchaseFlow\Processor\PointRateProcessor arguments: - - '@Eccube\Repository\DeliveryRepository' + - '@Eccube\Repository\BaseInfoRepository' tags: - - { name: eccube.item.holder.post.validator, flow_type: cart, priority: 100 } + - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 100 } - eccube.purchase.flow.item.holder.post.validator.add.point.processor: + eccube.purchase.flow.item.holder.post.validator.add.point.validator: # 加算ポイントの計算 class: Eccube\Service\PurchaseFlow\Processor\AddPointProcessor arguments: - '@Eccube\Repository\BaseInfoRepository' tags: - - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 100 } + - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 90 } - { name: eccube.item.holder.post.validator, flow_type: order, priority: 100 } + eccube.purchase.flow.item.holder.post.validator.payment.validator: # 使用できない支払い方法が含まれていないかどうか + class: Eccube\Service\PurchaseFlow\Processor\PaymentValidator + arguments: + - '@Eccube\Repository\DeliveryRepository' + tags: + - { name: eccube.item.holder.post.validator, flow_type: cart, priority: 100 } + - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 80 } + eccube.purchase.flow.item.holder.post.validator.payment.total.limit.validator: # 支払金額の上限チェック class: Eccube\Service\PurchaseFlow\Processor\PaymentTotalLimitValidator arguments: - '@Eccube\Common\EccubeConfig' tags: - { name: eccube.item.holder.post.validator, flow_type: cart, priority: 90 } - - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 90 } + - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 70 } - { name: eccube.item.holder.post.validator, flow_type: order, priority: 90 } eccube.purchase.flow.item.holder.post.validator.total.negative.validator: # 支払金額のマイナスチェック class: Eccube\Service\PurchaseFlow\Processor\PaymentTotalNegativeValidator tags: - { name: eccube.item.holder.post.validator, flow_type: cart, priority: 80 } - - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 80 } + - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 60 } - { name: eccube.item.holder.post.validator, flow_type: order, priority: 80 } eccube.purchase.flow.item.holder.post.validator.payment.charge.change.validator: # 手数料の変更検知 class: Eccube\Service\PurchaseFlow\Processor\PaymentChargeChangeValidator tags: - - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 70 } + - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 50 } eccube.purcahse.flow.item.holder.post.validator.delivery.fee.change.validator: # 送料の変更検知 class: Eccube\Service\PurchaseFlow\Processor\DeliveryFeeChangeValidator tags: - - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 60 } + - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 40 } + + eccube.purcahse.flow.item.holder.post.validator.tax.rate.change.validator: # 税率の変更検知 + class: Eccube\Service\PurchaseFlow\Processor\TaxRateChangeValidator + tags: + - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 30 } # addPurchaseProcessor eccybe.purchase.flow.purchase.processor.pre.order.id.validator: @@ -220,19 +239,19 @@ services: - '@Eccube\Repository\ProductStockRepository' - '@doctrine.orm.default_entity_manager' tags: - - { name: eccube.purchase.processor, flow_type: shopping, priority: 90 } + - { name: eccube.purchase.processor, flow_type: shopping, priority: 80 } eccube.purchase.flow.purchase.processor.customer.purchase.info.processor: class: Eccube\Service\PurchaseFlow\Processor\CustomerPurchaseInfoProcessor tags: - - { name: eccube.purchase.processor, flow_type: shopping, priority: 80 } + - { name: eccube.purchase.processor, flow_type: shopping, priority: 70 } eccube.purchase.flow.purchase.processor.order.update.processor: class: Eccube\Service\PurchaseFlow\Processor\OrderUpdateProcessor arguments: - '@Eccube\Repository\Master\OrderStatusRepository' tags: - - { name: eccube.purchase.processor, flow_type: shopping, priority: 70 } + - { name: eccube.purchase.processor, flow_type: shopping, priority: 60 } eccube.purchase.flow.purchase.processor.stock.diff.processor: class: Eccube\Service\PurchaseFlow\Processor\StockDiffProcessor diff --git a/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php b/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php index dce9e7d5d88..6b61d60f4aa 100644 --- a/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php +++ b/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php @@ -28,12 +28,12 @@ class PurchaseFlowPass implements CompilerPassInterface { use PriorityTaggedServiceTrait; - public const ITEM_PREPROCESSOR_TAG = 'eccube.item.preprocessor'; public const ITEM_VALIDATOR_TAG = 'eccube.item.validator'; - public const ITEM_HOLDER_PREPROCESSOR_TAG = 'eccube.item.holder.preprocessor'; public const ITEM_HOLDER_VALIDATOR_TAG = 'eccube.item.holder.validator'; - public const ITEM_HOLDER_POST_VALIDATOR_TAG = 'eccube.item.holder.post.validator'; + public const ITEM_PREPROCESSOR_TAG = 'eccube.item.preprocessor'; + public const ITEM_HOLDER_PREPROCESSOR_TAG = 'eccube.item.holder.preprocessor'; public const DISCOUNT_PROCESSOR_TAG = 'eccube.discount.processor'; + public const ITEM_HOLDER_POST_VALIDATOR_TAG = 'eccube.item.holder.post.validator'; public const PURCHASE_PROCESSOR_TAG = 'eccube.purchase.processor'; public function process(ContainerBuilder $container) From e8c8393953330f4559e0a500f3b63724988a0d7d Mon Sep 17 00:00:00 2001 From: kurozumi Date: Thu, 22 Feb 2024 11:19:46 +0900 Subject: [PATCH 10/21] =?UTF-8?q?=E5=90=84=E5=87=A6=E7=90=86=E3=81=AE?= =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DependencyInjection/Compiler/PurchaseFlowPass.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php b/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php index 6b61d60f4aa..1c9704102a0 100644 --- a/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php +++ b/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php @@ -44,6 +44,9 @@ public function process(ContainerBuilder $container) PurchaseContext::ORDER_FLOW => $container->findDefinition('eccube.purchase.flow.order') ]; + /** + * purchaseflow.yamlに定義を追加した場合の処理 + */ foreach ($this->getProcessorTags() as $tag => $methodName) { foreach ($this->findAndSortTaggedServices($tag, $container) as $id) { $def = $container->findDefinition($id); @@ -68,6 +71,9 @@ public function process(ContainerBuilder $container) AnnotationRegistry::registerAutoloadNamespace('Eccube\Annotation', __DIR__.'/../../../../src'); $reader = new AnnotationReader(); + /** + * アノテーションで追加対象のフローを指定した場合の処理 + */ foreach ($this->getProcessorTags() as $tag => $methodName) { $ids = $container->findTaggedServiceIds($tag); foreach ($ids as $id => $tags) { @@ -86,7 +92,7 @@ public function process(ContainerBuilder $container) /** * @return string[] */ - public function getProcessorTags(): array + private function getProcessorTags(): array { return [ self::ITEM_PREPROCESSOR_TAG => 'addItemPreprocessor', From 6f39ef2994e779b48ed0308f80be72e29127b478 Mon Sep 17 00:00:00 2001 From: kurozumi Date: Thu, 14 Mar 2024 11:12:55 +0900 Subject: [PATCH 11/21] =?UTF-8?q?=E3=82=A2=E3=83=8E=E3=83=86=E3=83=BC?= =?UTF-8?q?=E3=82=B7=E3=83=A7=E3=83=B3=E3=81=A8yaml=E3=81=A7=E9=87=8D?= =?UTF-8?q?=E8=A4=87=E3=81=97=E3=81=9F=E3=83=97=E3=83=AD=E3=82=BB=E3=83=83?= =?UTF-8?q?=E3=82=B5=E3=83=BC=E3=81=8C=E6=8C=87=E5=AE=9A=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=81=9F=E5=A0=B4=E5=90=88=E3=81=AFyaml=E6=8C=87=E5=AE=9A?= =?UTF-8?q?=E3=81=AE=E3=81=BF=E7=99=BB=E9=8C=B2=E3=81=95=E3=82=8C=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Compiler/PurchaseFlowPass.php | 5 +-- .../Service/PurchaseFlow/PurchaseFlow.php | 35 +++++++++++++------ 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php b/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php index 1c9704102a0..e7c60c0284c 100644 --- a/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php +++ b/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php @@ -22,6 +22,7 @@ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; class PurchaseFlowPass implements CompilerPassInterface @@ -41,7 +42,7 @@ public function process(ContainerBuilder $container) $flowTypes = [ PurchaseContext::CART_FLOW => $container->findDefinition('eccube.purchase.flow.cart'), PurchaseContext::SHOPPING_FLOW => $container->findDefinition('eccube.purchase.flow.shopping'), - PurchaseContext::ORDER_FLOW => $container->findDefinition('eccube.purchase.flow.order') + PurchaseContext::ORDER_FLOW => $container->findDefinition('eccube.purchase.flow.order'), ]; /** @@ -68,7 +69,7 @@ public function process(ContainerBuilder $container) OrderFlow::class => $container->findDefinition('eccube.purchase.flow.order'), ]; - AnnotationRegistry::registerAutoloadNamespace('Eccube\Annotation', __DIR__.'/../../../../src'); + AnnotationRegistry::registerAutoloadNamespace('Eccube\Annotation', __DIR__ . '/../../../../src'); $reader = new AnnotationReader(); /** diff --git a/src/Eccube/Service/PurchaseFlow/PurchaseFlow.php b/src/Eccube/Service/PurchaseFlow/PurchaseFlow.php index 7372f7bdcbd..c2153badee4 100644 --- a/src/Eccube/Service/PurchaseFlow/PurchaseFlow.php +++ b/src/Eccube/Service/PurchaseFlow/PurchaseFlow.php @@ -121,6 +121,7 @@ public function validate(ItemHolderInterface $itemHolder, PurchaseContext $conte foreach ($itemHolder->getItems() as $item) { foreach ($this->itemValidators as $itemValidator) { + var_dump(get_class($itemValidator)); $result = $itemValidator->execute($item, $context); $flowResult->addProcessResult($result); } @@ -227,37 +228,51 @@ public function rollback(ItemHolderInterface $target, PurchaseContext $context) public function addPurchaseProcessor(PurchaseProcessor $processor) { - $this->purchaseProcessors[] = $processor; + if (false === $this->purchaseProcessors->contains($processor)) { + $this->purchaseProcessors[] = $processor; + } } public function addItemHolderPreprocessor(ItemHolderPreprocessor $holderPreprocessor) { - $this->itemHolderPreprocessors[] = $holderPreprocessor; + if (false === $this->itemHolderPreprocessors->contains($holderPreprocessor)) { + $this->itemHolderPreprocessors[] = $holderPreprocessor; + } } public function addItemPreprocessor(ItemPreprocessor $itemPreprocessor) { - $this->itemPreprocessors[] = $itemPreprocessor; + if (false === $this->itemPreprocessors->contains($itemPreprocessor)) { + $this->itemPreprocessors[] = $itemPreprocessor; + } } public function addItemValidator(ItemValidator $itemValidator) { - $this->itemValidators[] = $itemValidator; + if (false === $this->itemValidators->contains($itemValidator)) { + $this->itemValidators[] = $itemValidator; + } } public function addItemHolderValidator(ItemHolderValidator $itemHolderValidator) { - $this->itemHolderValidators[] = $itemHolderValidator; + if (false === $this->itemHolderValidators->contains($itemHolderValidator)) { + $this->itemHolderValidators[] = $itemHolderValidator; + } } public function addItemHolderPostValidator(ItemHolderPostValidator $itemHolderValidator) { - $this->itemHolderPostValidators[] = $itemHolderValidator; + if (false === $this->itemHolderPostValidators->contains($itemHolderValidator)) { + $this->itemHolderPostValidators[] = $itemHolderValidator; + } } public function addDiscountProcessor(DiscountProcessor $discountProcessor) { - $this->discountProcessors[] = $discountProcessor; + if (false === $this->discountProcessors->contains($discountProcessor)) { + $this->discountProcessors[] = $discountProcessor; + } } /** @@ -384,7 +399,7 @@ public function dump() return get_class($processor); }; $flows = [ - 0 => $this->flowType.' flow', + 0 => $this->flowType . ' flow', 'ItemValidator' => $this->itemValidators->map($callback)->toArray(), 'ItemHolderValidator' => $this->itemHolderValidators->map($callback)->toArray(), 'ItemPreprocessor' => $this->itemPreprocessors->map($callback)->toArray(), @@ -401,9 +416,9 @@ public function dump() $out = ''; foreach ($tree as $key => $value) { if (is_numeric($key)) { - $out .= $value.PHP_EOL; + $out .= $value . PHP_EOL; } else { - $out .= $key.PHP_EOL; + $out .= $key . PHP_EOL; } } From 0fea674b2eae7e382a33b8f700c75df173eac80e Mon Sep 17 00:00:00 2001 From: kurozumi Date: Thu, 14 Mar 2024 11:14:05 +0900 Subject: [PATCH 12/21] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AA=E3=82=B3?= =?UTF-8?q?=E3=83=BC=E3=83=89=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Eccube/Service/PurchaseFlow/PurchaseFlow.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Eccube/Service/PurchaseFlow/PurchaseFlow.php b/src/Eccube/Service/PurchaseFlow/PurchaseFlow.php index c2153badee4..39d1f354333 100644 --- a/src/Eccube/Service/PurchaseFlow/PurchaseFlow.php +++ b/src/Eccube/Service/PurchaseFlow/PurchaseFlow.php @@ -121,7 +121,6 @@ public function validate(ItemHolderInterface $itemHolder, PurchaseContext $conte foreach ($itemHolder->getItems() as $item) { foreach ($this->itemValidators as $itemValidator) { - var_dump(get_class($itemValidator)); $result = $itemValidator->execute($item, $context); $flowResult->addProcessResult($result); } From c513b375213b070148cf21fb95881a88d2544096 Mon Sep 17 00:00:00 2001 From: kurozumi Date: Thu, 14 Mar 2024 11:16:43 +0900 Subject: [PATCH 13/21] =?UTF-8?q?=E3=82=B3=E3=83=B3=E3=83=95=E3=83=AA?= =?UTF-8?q?=E3=82=AF=E3=83=88=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php b/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php index e7c60c0284c..e4a0312c1b4 100644 --- a/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php +++ b/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php @@ -69,7 +69,8 @@ public function process(ContainerBuilder $container) OrderFlow::class => $container->findDefinition('eccube.purchase.flow.order'), ]; - AnnotationRegistry::registerAutoloadNamespace('Eccube\Annotation', __DIR__ . '/../../../../src'); + // TODO doctrine/anntationsをv2へアップデート。影響がある場合は要調査。 + //AnnotationRegistry::registerAutoloadNamespace('Eccube\Annotation', __DIR__.'/../../../../src'); $reader = new AnnotationReader(); /** From afdf1b85ac8d8f6a93d7b7e180bacdbbb9b69b61 Mon Sep 17 00:00:00 2001 From: kurozumi Date: Thu, 14 Mar 2024 11:35:20 +0900 Subject: [PATCH 14/21] =?UTF-8?q?Revert=20"=E3=82=B3=E3=83=B3=E3=83=95?= =?UTF-8?q?=E3=83=AA=E3=82=AF=E3=83=88=E4=BF=AE=E6=AD=A3"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit c513b375213b070148cf21fb95881a88d2544096. --- src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php b/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php index 9dfc7fe7786..7b5f26a2117 100644 --- a/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php +++ b/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php @@ -67,8 +67,7 @@ public function process(ContainerBuilder $container) OrderFlow::class => $container->findDefinition('eccube.purchase.flow.order'), ]; - // TODO doctrine/anntationsをv2へアップデート。影響がある場合は要調査。 - //AnnotationRegistry::registerAutoloadNamespace('Eccube\Annotation', __DIR__.'/../../../../src'); + AnnotationRegistry::registerAutoloadNamespace('Eccube\Annotation', __DIR__ . '/../../../../src'); $reader = new AnnotationReader(); /** From d0a1d548e8085a8eca567547afb9c2ff459ff123 Mon Sep 17 00:00:00 2001 From: kurozumi Date: Thu, 14 Mar 2024 11:51:52 +0900 Subject: [PATCH 15/21] =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php b/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php index 7b5f26a2117..df100104281 100644 --- a/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php +++ b/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php @@ -67,7 +67,7 @@ public function process(ContainerBuilder $container) OrderFlow::class => $container->findDefinition('eccube.purchase.flow.order'), ]; - AnnotationRegistry::registerAutoloadNamespace('Eccube\Annotation', __DIR__ . '/../../../../src'); + //AnnotationRegistry::registerAutoloadNamespace('Eccube\Annotation', __DIR__ . '/../../../../src'); $reader = new AnnotationReader(); /** From 0dcef1066d1a662fab069f1dc95c331ed9f52db3 Mon Sep 17 00:00:00 2001 From: kurozumi Date: Thu, 14 Mar 2024 12:22:46 +0900 Subject: [PATCH 16/21] =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php b/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php index df100104281..349aea04e68 100644 --- a/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php +++ b/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php @@ -14,6 +14,7 @@ namespace Eccube\DependencyInjection\Compiler; use Doctrine\Common\Annotations\AnnotationReader; +use Doctrine\Common\Annotations\AnnotationRegistry; use Eccube\Annotation\CartFlow; use Eccube\Annotation\OrderFlow; use Eccube\Annotation\ShoppingFlow; @@ -67,6 +68,7 @@ public function process(ContainerBuilder $container) OrderFlow::class => $container->findDefinition('eccube.purchase.flow.order'), ]; + // TODO doctrine/anntationsをv2へアップデート。影響がある場合は要調査。 //AnnotationRegistry::registerAutoloadNamespace('Eccube\Annotation', __DIR__ . '/../../../../src'); $reader = new AnnotationReader(); From 7ee3445436c33f5a58a0777208ba070837dc9fa2 Mon Sep 17 00:00:00 2001 From: kurozumi Date: Tue, 9 Apr 2024 14:59:13 +0900 Subject: [PATCH 17/21] =?UTF-8?q?=E3=83=97=E3=83=AD=E3=82=BB=E3=83=83?= =?UTF-8?q?=E3=82=B5=E3=83=BC=E3=81=AE=E7=99=BB=E9=8C=B2=E3=83=81=E3=82=A7?= =?UTF-8?q?=E3=83=83=E3=82=AF=E5=87=A6=E7=90=86=E3=82=92=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/PurchaseFlow/PurchaseFlow.php | 38 +++++++++++++------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/src/Eccube/Service/PurchaseFlow/PurchaseFlow.php b/src/Eccube/Service/PurchaseFlow/PurchaseFlow.php index 39d1f354333..5a3c7e9d645 100644 --- a/src/Eccube/Service/PurchaseFlow/PurchaseFlow.php +++ b/src/Eccube/Service/PurchaseFlow/PurchaseFlow.php @@ -225,51 +225,65 @@ public function rollback(ItemHolderInterface $target, PurchaseContext $context) } } - public function addPurchaseProcessor(PurchaseProcessor $processor) + public function addPurchaseProcessor(PurchaseProcessor $purchaseProcessor) { - if (false === $this->purchaseProcessors->contains($processor)) { - $this->purchaseProcessors[] = $processor; + if (0 === $this->purchaseProcessors->filter(function ($processor) use ($purchaseProcessor) { + return get_class($processor) === get_class($purchaseProcessor); + })->count()) { + $this->purchaseProcessors[] = $purchaseProcessor; } } public function addItemHolderPreprocessor(ItemHolderPreprocessor $holderPreprocessor) { - if (false === $this->itemHolderPreprocessors->contains($holderPreprocessor)) { + if (0 === $this->itemHolderPreprocessors->filter(function ($processor) use ($holderPreprocessor) { + return get_class($processor) === get_class($holderPreprocessor); + })->count()) { $this->itemHolderPreprocessors[] = $holderPreprocessor; } } public function addItemPreprocessor(ItemPreprocessor $itemPreprocessor) { - if (false === $this->itemPreprocessors->contains($itemPreprocessor)) { + if (0 === $this->itemPreprocessors->filter(function ($processor) use ($itemPreprocessor) { + return get_class($processor) === get_class($itemPreprocessor); + })->count()) { $this->itemPreprocessors[] = $itemPreprocessor; } } public function addItemValidator(ItemValidator $itemValidator) { - if (false === $this->itemValidators->contains($itemValidator)) { + if (0 === $this->itemValidators->filter(function ($processor) use ($itemValidator) { + return get_class($processor) === get_class($itemValidator); + })->count()) { $this->itemValidators[] = $itemValidator; } } public function addItemHolderValidator(ItemHolderValidator $itemHolderValidator) { - if (false === $this->itemHolderValidators->contains($itemHolderValidator)) { + if (0 === $this->itemHolderValidators->filter(function ($processor) use ($itemHolderValidator) { + return get_class($processor) === get_class($itemHolderValidator); + })->count()) { $this->itemHolderValidators[] = $itemHolderValidator; } } public function addItemHolderPostValidator(ItemHolderPostValidator $itemHolderValidator) { - if (false === $this->itemHolderPostValidators->contains($itemHolderValidator)) { + if (0 === $this->itemHolderPostValidators->filter(function ($processor) use ($itemHolderValidator) { + return get_class($processor) === get_class($itemHolderValidator); + })->count()) { $this->itemHolderPostValidators[] = $itemHolderValidator; } } public function addDiscountProcessor(DiscountProcessor $discountProcessor) { - if (false === $this->discountProcessors->contains($discountProcessor)) { + if (0 === $this->discountProcessors->filter(function ($processor) use ($discountProcessor) { + return get_class($processor) === get_class($discountProcessor); + })->count()) { $this->discountProcessors[] = $discountProcessor; } } @@ -398,7 +412,7 @@ public function dump() return get_class($processor); }; $flows = [ - 0 => $this->flowType . ' flow', + 0 => $this->flowType.' flow', 'ItemValidator' => $this->itemValidators->map($callback)->toArray(), 'ItemHolderValidator' => $this->itemHolderValidators->map($callback)->toArray(), 'ItemPreprocessor' => $this->itemPreprocessors->map($callback)->toArray(), @@ -415,9 +429,9 @@ public function dump() $out = ''; foreach ($tree as $key => $value) { if (is_numeric($key)) { - $out .= $value . PHP_EOL; + $out .= $value.PHP_EOL; } else { - $out .= $key . PHP_EOL; + $out .= $key.PHP_EOL; } } From 35f9990e13bac61112fadb703aaf741413349d3e Mon Sep 17 00:00:00 2001 From: kurozumi Date: Tue, 9 Apr 2024 15:40:36 +0900 Subject: [PATCH 18/21] =?UTF-8?q?=E3=83=97=E3=83=AD=E3=82=BB=E3=83=83?= =?UTF-8?q?=E3=82=B5=E3=83=BC=E3=81=AE=E7=99=BB=E9=8C=B2=E3=83=81=E3=82=A7?= =?UTF-8?q?=E3=83=83=E3=82=AF=E5=87=A6=E7=90=86=E3=81=AE=E9=96=A2=E6=95=B0?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/PurchaseFlow/PurchaseFlow.php | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/Eccube/Service/PurchaseFlow/PurchaseFlow.php b/src/Eccube/Service/PurchaseFlow/PurchaseFlow.php index 5a3c7e9d645..56459dae5a3 100644 --- a/src/Eccube/Service/PurchaseFlow/PurchaseFlow.php +++ b/src/Eccube/Service/PurchaseFlow/PurchaseFlow.php @@ -227,63 +227,49 @@ public function rollback(ItemHolderInterface $target, PurchaseContext $context) public function addPurchaseProcessor(PurchaseProcessor $purchaseProcessor) { - if (0 === $this->purchaseProcessors->filter(function ($processor) use ($purchaseProcessor) { - return get_class($processor) === get_class($purchaseProcessor); - })->count()) { + if (false === $this->containsProcessor($this->purchaseProcessors, $purchaseProcessor)) { $this->purchaseProcessors[] = $purchaseProcessor; } } public function addItemHolderPreprocessor(ItemHolderPreprocessor $holderPreprocessor) { - if (0 === $this->itemHolderPreprocessors->filter(function ($processor) use ($holderPreprocessor) { - return get_class($processor) === get_class($holderPreprocessor); - })->count()) { + if (false === $this->containsProcessor($this->itemHolderPreprocessors, $holderPreprocessor)) { $this->itemHolderPreprocessors[] = $holderPreprocessor; } } public function addItemPreprocessor(ItemPreprocessor $itemPreprocessor) { - if (0 === $this->itemPreprocessors->filter(function ($processor) use ($itemPreprocessor) { - return get_class($processor) === get_class($itemPreprocessor); - })->count()) { + if (false === $this->containsProcessor($this->itemPreprocessors, $itemPreprocessor)) { $this->itemPreprocessors[] = $itemPreprocessor; } } public function addItemValidator(ItemValidator $itemValidator) { - if (0 === $this->itemValidators->filter(function ($processor) use ($itemValidator) { - return get_class($processor) === get_class($itemValidator); - })->count()) { + if (false === $this->containsProcessor($this->itemValidators, $itemValidator)) { $this->itemValidators[] = $itemValidator; } } public function addItemHolderValidator(ItemHolderValidator $itemHolderValidator) { - if (0 === $this->itemHolderValidators->filter(function ($processor) use ($itemHolderValidator) { - return get_class($processor) === get_class($itemHolderValidator); - })->count()) { + if (false === $this->containsProcessor($this->itemHolderValidators, $itemHolderValidator)) { $this->itemHolderValidators[] = $itemHolderValidator; } } public function addItemHolderPostValidator(ItemHolderPostValidator $itemHolderValidator) { - if (0 === $this->itemHolderPostValidators->filter(function ($processor) use ($itemHolderValidator) { - return get_class($processor) === get_class($itemHolderValidator); - })->count()) { + if (false === $this->containsProcessor($this->itemHolderPostValidators, $itemHolderValidator)) { $this->itemHolderPostValidators[] = $itemHolderValidator; } } public function addDiscountProcessor(DiscountProcessor $discountProcessor) { - if (0 === $this->discountProcessors->filter(function ($processor) use ($discountProcessor) { - return get_class($processor) === get_class($discountProcessor); - })->count()) { + if (false === $this->containsProcessor($this->discountProcessors, $discountProcessor)) { $this->discountProcessors[] = $discountProcessor; } } @@ -445,4 +431,17 @@ public function __toString() { return $this->dump(); } + + /** + * @param ArrayCollection $processors + * @param $processor + * + * @return bool + */ + protected function containsProcessor(ArrayCollection $processors, $processor): bool + { + return $processors->filter(function ($proc) use ($processor) { + return get_class($proc) === get_class($processor); + })->count() > 0; + } } From ce76a9d1697a5ad135d330708b8b79c7835f5aa5 Mon Sep 17 00:00:00 2001 From: daichi_otani Date: Wed, 10 Apr 2024 16:09:58 +0900 Subject: [PATCH 19/21] =?UTF-8?q?1000=E5=A7=8B=E3=81=BE=E3=82=8A=E3=81=AE1?= =?UTF-8?q?00=E5=88=BB=E3=81=BF=E3=81=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/config/eccube/packages/purchaseflow.yaml | 92 ++++++++++---------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/app/config/eccube/packages/purchaseflow.yaml b/app/config/eccube/packages/purchaseflow.yaml index a6a6b8097e9..e4b3c03b9be 100644 --- a/app/config/eccube/packages/purchaseflow.yaml +++ b/app/config/eccube/packages/purchaseflow.yaml @@ -25,36 +25,36 @@ services: arguments: - '@Eccube\Repository\DeliveryRepository' tags: - - { name: eccube.item.validator, flow_type: cart, priority: 100 } - - { name: eccube.item.validator, flow_type: shopping, priority: 100 } + - { name: eccube.item.validator, flow_type: cart, priority: 1000 } + - { name: eccube.item.validator, flow_type: shopping, priority: 1000 } eccube.purchase.flow.item.validator.product.status.validator: # 商品の公開状態のチェック class: Eccube\Service\PurchaseFlow\Processor\ProductStatusValidator tags: - - { name: eccube.item.validator, flow_type: cart, priority: 90 } - - { name: eccube.item.validator, flow_type: shopping, priority: 90 } + - { name: eccube.item.validator, flow_type: cart, priority: 900 } + - { name: eccube.item.validator, flow_type: shopping, priority: 900 } eccube.purchase.flow.item.validator.price.change.validator: # 商品価格の変更検知 class: Eccube\Service\PurchaseFlow\Processor\PriceChangeValidator tags: - - { name: eccube.item.validator, flow_type: cart, priority: 80 } - - { name: eccube.item.validator, flow_type: shopping, priority: 80 } + - { name: eccube.item.validator, flow_type: cart, priority: 800 } + - { name: eccube.item.validator, flow_type: shopping, priority: 800 } eccube.purchase.flow.item.validator.stock.validator: # 在庫のチェック class: Eccube\Service\PurchaseFlow\Processor\StockValidator tags: - - { name: eccube.item.validator, flow_type: cart, priority: 70 } + - { name: eccube.item.validator, flow_type: cart, priority: 700 } eccube.purchase.flow.item.validator.sale.limit.validator: # 販売制限数のチェック class: Eccube\Service\PurchaseFlow\Processor\SaleLimitValidator tags: - - { name: eccube.item.validator, flow_type: cart, priority: 60 } + - { name: eccube.item.validator, flow_type: cart, priority: 600 } eccube.purchase.flow.item.validator.class_category.validator: # 販売制限数のチェック class: Eccube\Service\PurchaseFlow\Processor\ClassCategoryValidator tags: - - { name: eccube.item.validator, flow_type: cart, priority: 50 } - - { name: eccube.item.validator, flow_type: shopping, priority: 50 } + - { name: eccube.item.validator, flow_type: cart, priority: 500 } + - { name: eccube.item.validator, flow_type: shopping, priority: 500 } # addItemHolderValidator eccube.purchase.flow.item.holder.validator.stock.multiple.validator: @@ -62,29 +62,29 @@ services: arguments: - '@Eccube\Repository\ProductClassRepository' tags: - - { name: eccube.item.holder.validator, flow_type: shopping, priority: 100 } + - { name: eccube.item.holder.validator, flow_type: shopping, priority: 1000 } eccube.purchase.flow.item.holder.validator.sale.limit.multiple.validator: class: Eccube\Service\PurchaseFlow\Processor\SaleLimitMultipleValidator arguments: - '@Eccube\Repository\ProductClassRepository' tags: - - { name: eccube.item.holder.validator, flow_type: shopping, priority: 90 } + - { name: eccube.item.holder.validator, flow_type: shopping, priority: 900 } eccube.purchase.flow.item.holder.validator.empty.items.validator: # 空明細の削除処理 class: Eccube\Service\PurchaseFlow\Processor\EmptyItemsValidator arguments: - '@doctrine.orm.default_entity_manager' tags: - - { name: eccube.item.holder.validator, flow_type: cart, priority: 100 } - - { name: eccube.item.holder.validator, flow_type: shopping, priority: 80 } + - { name: eccube.item.holder.validator, flow_type: cart, priority: 1000 } + - { name: eccube.item.holder.validator, flow_type: shopping, priority: 800 } eccube.purchase.flow.item.holder.validator.stock.diff.processor: class: Eccube\Service\PurchaseFlow\Processor\StockDiffProcessor arguments: - '@Eccube\Repository\ProductClassRepository' tags: - - { name: eccube.item.holder.validator, flow_type: order, priority: 100 } + - { name: eccube.item.holder.validator, flow_type: order, priority: 1000 } eccube.purchase.flow.item.holder.validator.point.diff.processor: class: Eccube\Service\PurchaseFlow\Processor\PointDiffProcessor @@ -92,7 +92,7 @@ services: - '@doctrine.orm.default_entity_manager' - '@Eccube\Service\PointHelper' tags: - - { name: eccube.item.holder.validator, flow_type: order, priority: 90 } + - { name: eccube.item.holder.validator, flow_type: order, priority: 900 } # addItemPreprocessor @@ -105,8 +105,8 @@ services: - '@Eccube\Service\TaxRuleService' - '@Eccube\Service\OrderHelper' tags: - - { name: eccube.item.holder.preprocessor, flow_type: shopping, priority: 100 } - - { name: eccube.item.holder.preprocessor, flow_type: order, priority: 100 } + - { name: eccube.item.holder.preprocessor, flow_type: shopping, priority: 1000 } + - { name: eccube.item.holder.preprocessor, flow_type: order, priority: 1000 } eccube.purchase.flow.item.holder.preprocessor.order.no.processor: class: Eccube\Service\PurchaseFlow\Processor\OrderNoProcessor @@ -114,7 +114,7 @@ services: - '@Eccube\Common\EccubeConfig' - '@Eccube\Repository\OrderRepository' tags: - - { name: eccube.item.holder.preprocessor, flow_type: shopping, priority: 90 } + - { name: eccube.item.holder.preprocessor, flow_type: shopping, priority: 900 } eccube.purchase.flow.item.holder.preprocessor.delivery.fee.preprocessor: class: Eccube\Service\PurchaseFlow\Processor\DeliveryFeePreprocessor @@ -124,14 +124,14 @@ services: - '@Eccube\Repository\TaxRuleRepository' - '@Eccube\Repository\DeliveryFeeRepository' tags: - - { name: eccube.item.holder.preprocessor, flow_type: shopping, priority: 80 } + - { name: eccube.item.holder.preprocessor, flow_type: shopping, priority: 800 } eccube.purchase.flow.item.holder.preprocessor.delivery.fee.free.by.shipping.preprocessor: class: Eccube\Service\PurchaseFlow\Processor\DeliveryFeeFreeByShippingPreprocessor arguments: - '@Eccube\Repository\BaseInfoRepository' tags: - - { name: eccube.item.holder.preprocessor, flow_type: shopping, priority: 70 } + - { name: eccube.item.holder.preprocessor, flow_type: shopping, priority: 700 } eccube.purchase.flow.item.holder.preprocessor.pyament.charge.preprocessor: class: Eccube\Service\PurchaseFlow\Processor\PaymentChargePreprocessor @@ -140,7 +140,7 @@ services: - '@Eccube\Repository\Master\TaxDisplayTypeRepository' - '@Eccube\Repository\Master\TaxTypeRepository' tags: - - { name: eccube.item.holder.preprocessor, flow_type: shopping, priority: 50 } + - { name: eccube.item.holder.preprocessor, flow_type: shopping, priority: 500 } eccube.purchase.flow.item.holder.preprocessor.tax.processor.after: # 税額の計算(送料明細・手数料明細に対して税額を計算) class: Eccube\Service\PurchaseFlow\Processor\TaxProcessor @@ -150,7 +150,7 @@ services: - '@Eccube\Service\TaxRuleService' - '@Eccube\Service\OrderHelper' tags: - - { name: eccube.item.holder.preprocessor, flow_type: shopping, priority: 40 } + - { name: eccube.item.holder.preprocessor, flow_type: shopping, priority: 400 } # addDiscountProcessor eccube.purchase.flow.discount.processor.point.processor: @@ -159,8 +159,8 @@ services: - '@doctrine.orm.default_entity_manager' - '@Eccube\Service\PointHelper' tags: - - { name: eccube.discount.processor, flow_type: shopping, priority: 100 } - - { name: eccube.discount.processor, flow_type: order, priority: 100 } + - { name: eccube.discount.processor, flow_type: shopping, priority: 1000 } + - { name: eccube.discount.processor, flow_type: order, priority: 1000 } # addItemHolderPostValidator eccube.purchase.flow.item.holder.post.validator.point.rate.validator: # 明細にポイント付与率を設定する @@ -168,54 +168,54 @@ services: arguments: - '@Eccube\Repository\BaseInfoRepository' tags: - - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 100 } + - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 1000 } eccube.purchase.flow.item.holder.post.validator.add.point.validator: # 加算ポイントの計算 class: Eccube\Service\PurchaseFlow\Processor\AddPointProcessor arguments: - '@Eccube\Repository\BaseInfoRepository' tags: - - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 90 } - - { name: eccube.item.holder.post.validator, flow_type: order, priority: 100 } + - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 900 } + - { name: eccube.item.holder.post.validator, flow_type: order, priority: 1000 } eccube.purchase.flow.item.holder.post.validator.payment.validator: # 使用できない支払い方法が含まれていないかどうか class: Eccube\Service\PurchaseFlow\Processor\PaymentValidator arguments: - '@Eccube\Repository\DeliveryRepository' tags: - - { name: eccube.item.holder.post.validator, flow_type: cart, priority: 100 } - - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 80 } + - { name: eccube.item.holder.post.validator, flow_type: cart, priority: 1000 } + - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 800 } eccube.purchase.flow.item.holder.post.validator.payment.total.limit.validator: # 支払金額の上限チェック class: Eccube\Service\PurchaseFlow\Processor\PaymentTotalLimitValidator arguments: - '@Eccube\Common\EccubeConfig' tags: - - { name: eccube.item.holder.post.validator, flow_type: cart, priority: 90 } - - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 70 } - - { name: eccube.item.holder.post.validator, flow_type: order, priority: 90 } + - { name: eccube.item.holder.post.validator, flow_type: cart, priority: 900 } + - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 700 } + - { name: eccube.item.holder.post.validator, flow_type: order, priority: 900 } eccube.purchase.flow.item.holder.post.validator.total.negative.validator: # 支払金額のマイナスチェック class: Eccube\Service\PurchaseFlow\Processor\PaymentTotalNegativeValidator tags: - - { name: eccube.item.holder.post.validator, flow_type: cart, priority: 80 } - - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 60 } - - { name: eccube.item.holder.post.validator, flow_type: order, priority: 80 } + - { name: eccube.item.holder.post.validator, flow_type: cart, priority: 800 } + - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 600 } + - { name: eccube.item.holder.post.validator, flow_type: order, priority: 800 } eccube.purchase.flow.item.holder.post.validator.payment.charge.change.validator: # 手数料の変更検知 class: Eccube\Service\PurchaseFlow\Processor\PaymentChargeChangeValidator tags: - - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 50 } + - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 500 } eccube.purcahse.flow.item.holder.post.validator.delivery.fee.change.validator: # 送料の変更検知 class: Eccube\Service\PurchaseFlow\Processor\DeliveryFeeChangeValidator tags: - - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 40 } + - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 400 } eccube.purcahse.flow.item.holder.post.validator.tax.rate.change.validator: # 税率の変更検知 class: Eccube\Service\PurchaseFlow\Processor\TaxRateChangeValidator tags: - - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 30 } + - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 300 } # addPurchaseProcessor eccybe.purchase.flow.purchase.processor.pre.order.id.validator: @@ -223,7 +223,7 @@ services: arguments: - '@Eccube\Service\CartService' tags: - - { name: eccube.purchase.processor, flow_type: shopping, priority: 100 } + - { name: eccube.purchase.processor, flow_type: shopping, priority: 1000 } eccube.purchase.flow.purchase.processor.point.processor: class: Eccube\Service\PurchaseFlow\Processor\PointProcessor @@ -231,7 +231,7 @@ services: - '@doctrine.orm.default_entity_manager' - '@Eccube\Service\PointHelper' tags: - - { name: eccube.purchase.processor, flow_type: shopping, priority: 90 } + - { name: eccube.purchase.processor, flow_type: shopping, priority: 900 } eccube.purchase.flow.purchase.processor.stock.reduce.processor: class: Eccube\Service\PurchaseFlow\Processor\StockReduceProcessor @@ -239,26 +239,26 @@ services: - '@Eccube\Repository\ProductStockRepository' - '@doctrine.orm.default_entity_manager' tags: - - { name: eccube.purchase.processor, flow_type: shopping, priority: 80 } + - { name: eccube.purchase.processor, flow_type: shopping, priority: 800 } eccube.purchase.flow.purchase.processor.customer.purchase.info.processor: class: Eccube\Service\PurchaseFlow\Processor\CustomerPurchaseInfoProcessor tags: - - { name: eccube.purchase.processor, flow_type: shopping, priority: 70 } + - { name: eccube.purchase.processor, flow_type: shopping, priority: 700 } eccube.purchase.flow.purchase.processor.order.update.processor: class: Eccube\Service\PurchaseFlow\Processor\OrderUpdateProcessor arguments: - '@Eccube\Repository\Master\OrderStatusRepository' tags: - - { name: eccube.purchase.processor, flow_type: shopping, priority: 60 } + - { name: eccube.purchase.processor, flow_type: shopping, priority: 600 } eccube.purchase.flow.purchase.processor.stock.diff.processor: class: Eccube\Service\PurchaseFlow\Processor\StockDiffProcessor arguments: - '@Eccube\Repository\ProductClassRepository' tags: - - { name: eccube.purchase.processor, flow_type: order, priority: 100 } + - { name: eccube.purchase.processor, flow_type: order, priority: 1000 } eccube.purchase.flow.purchase.processor.point.diff.processor: class: Eccube\Service\PurchaseFlow\Processor\PointDiffProcessor @@ -266,4 +266,4 @@ services: - '@doctrine.orm.default_entity_manager' - '@Eccube\Service\PointHelper' tags: - - { name: eccube.purchase.processor, flow_type: order, priority: 90 } + - { name: eccube.purchase.processor, flow_type: order, priority: 900 } From 77d5aa516dd1f1942ae6280e7839ae1c2bf5979f Mon Sep 17 00:00:00 2001 From: kurozumi Date: Fri, 12 Apr 2024 14:27:54 +0900 Subject: [PATCH 20/21] =?UTF-8?q?=E3=83=97=E3=83=AD=E3=82=BB=E3=83=83?= =?UTF-8?q?=E3=82=B5=E3=83=BC=E3=81=AE=E9=87=8D=E8=A4=87=E3=83=81=E3=82=A7?= =?UTF-8?q?=E3=83=83=E3=82=AF=E3=82=92=E3=82=84=E3=82=81=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/config/eccube/packages/purchaseflow.yaml | 2 +- .../Compiler/PurchaseFlowPass.php | 18 +++++-- .../PurchaseFlow/Processor/TaxProcessor.php | 5 +- .../Service/PurchaseFlow/PurchaseFlow.php | 51 +++++-------------- 4 files changed, 31 insertions(+), 45 deletions(-) diff --git a/app/config/eccube/packages/purchaseflow.yaml b/app/config/eccube/packages/purchaseflow.yaml index e4b3c03b9be..9c57f69c168 100644 --- a/app/config/eccube/packages/purchaseflow.yaml +++ b/app/config/eccube/packages/purchaseflow.yaml @@ -50,7 +50,7 @@ services: tags: - { name: eccube.item.validator, flow_type: cart, priority: 600 } - eccube.purchase.flow.item.validator.class_category.validator: # 販売制限数のチェック + eccube.purchase.flow.item.validator.class_category.validator: # 商品規格の公開状態チェック class: Eccube\Service\PurchaseFlow\Processor\ClassCategoryValidator tags: - { name: eccube.item.validator, flow_type: cart, priority: 500 } diff --git a/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php b/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php index 349aea04e68..a01bf5c2b1a 100644 --- a/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php +++ b/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php @@ -22,6 +22,7 @@ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; class PurchaseFlowPass implements CompilerPassInterface @@ -48,13 +49,18 @@ public function process(ContainerBuilder $container) * purchaseflow.yamlに定義を追加した場合の処理 */ foreach ($this->getProcessorTags() as $tag => $methodName) { + /** @var Reference $id */ foreach ($this->findAndSortTaggedServices($tag, $container) as $id) { $def = $container->findDefinition($id); foreach ($def->getTag($tag) as $attributes) { if (isset($attributes['flow_type'])) { + /** + * @var string $flowType + * @var Definition $purchaseFlowDef + */ foreach ($flowTypes as $flowType => $purchaseFlowDef) { if ($flowType === $attributes['flow_type']) { - $purchaseFlowDef->addMethodCall($methodName, [new Reference($id)]); + $purchaseFlowDef->addMethodCall($methodName, [$id]); } } } @@ -76,13 +82,17 @@ public function process(ContainerBuilder $container) * アノテーションで追加対象のフローを指定した場合の処理 */ foreach ($this->getProcessorTags() as $tag => $methodName) { - $ids = $container->findTaggedServiceIds($tag); - foreach ($ids as $id => $tags) { + /** @var Reference $id */ + foreach ($this->findAndSortTaggedServices($tag, $container) as $id) { $def = $container->getDefinition($id); + /** + * @var string $annotationName + * @var Definition $purchaseFlowDef + */ foreach ($flowDefs as $annotationName => $purchaseFlowDef) { $anno = $reader->getClassAnnotation(new \ReflectionClass($def->getClass()), $annotationName); if ($anno) { - $purchaseFlowDef->addMethodCall($methodName, [new Reference($id)]); + $purchaseFlowDef->addMethodCall($methodName, [$id]); $purchaseFlowDef->setPublic(true); } } diff --git a/src/Eccube/Service/PurchaseFlow/Processor/TaxProcessor.php b/src/Eccube/Service/PurchaseFlow/Processor/TaxProcessor.php index 1514a77129e..974f03ce097 100644 --- a/src/Eccube/Service/PurchaseFlow/Processor/TaxProcessor.php +++ b/src/Eccube/Service/PurchaseFlow/Processor/TaxProcessor.php @@ -20,10 +20,10 @@ use Eccube\Entity\Master\TaxType; use Eccube\Entity\Order; use Eccube\Repository\TaxRuleRepository; +use Eccube\Service\OrderHelper; use Eccube\Service\PurchaseFlow\ItemHolderPreprocessor; use Eccube\Service\PurchaseFlow\PurchaseContext; use Eccube\Service\TaxRuleService; -use Eccube\Service\OrderHelper; class TaxProcessor implements ItemHolderPreprocessor { @@ -50,8 +50,10 @@ class TaxProcessor implements ItemHolderPreprocessor /** * TaxProcessor constructor. * + * @param EntityManagerInterface $entityManager * @param TaxRuleRepository $taxRuleRepository * @param TaxRuleService $taxRuleService + * @param OrderHelper $orderHelper */ public function __construct( EntityManagerInterface $entityManager, @@ -160,6 +162,7 @@ protected function getTaxType($OrderItemType) * - ポイント値引き: 税込 * * @param $OrderItemType + * * @deprecated OrderHelper::getTaxDisplayTypeを使用してください * * @return TaxDisplayType diff --git a/src/Eccube/Service/PurchaseFlow/PurchaseFlow.php b/src/Eccube/Service/PurchaseFlow/PurchaseFlow.php index 56459dae5a3..4212012aa30 100644 --- a/src/Eccube/Service/PurchaseFlow/PurchaseFlow.php +++ b/src/Eccube/Service/PurchaseFlow/PurchaseFlow.php @@ -227,51 +227,37 @@ public function rollback(ItemHolderInterface $target, PurchaseContext $context) public function addPurchaseProcessor(PurchaseProcessor $purchaseProcessor) { - if (false === $this->containsProcessor($this->purchaseProcessors, $purchaseProcessor)) { - $this->purchaseProcessors[] = $purchaseProcessor; - } + $this->purchaseProcessors[] = $purchaseProcessor; } - public function addItemHolderPreprocessor(ItemHolderPreprocessor $holderPreprocessor) + public function addItemHolderPreprocessor(ItemHolderPreprocessor $itemHolderPreprocessor) { - if (false === $this->containsProcessor($this->itemHolderPreprocessors, $holderPreprocessor)) { - $this->itemHolderPreprocessors[] = $holderPreprocessor; - } + $this->itemHolderPreprocessors[] = $itemHolderPreprocessor; } public function addItemPreprocessor(ItemPreprocessor $itemPreprocessor) { - if (false === $this->containsProcessor($this->itemPreprocessors, $itemPreprocessor)) { - $this->itemPreprocessors[] = $itemPreprocessor; - } + $this->itemPreprocessors[] = $itemPreprocessor; } public function addItemValidator(ItemValidator $itemValidator) { - if (false === $this->containsProcessor($this->itemValidators, $itemValidator)) { - $this->itemValidators[] = $itemValidator; - } + $this->itemValidators[] = $itemValidator; } public function addItemHolderValidator(ItemHolderValidator $itemHolderValidator) { - if (false === $this->containsProcessor($this->itemHolderValidators, $itemHolderValidator)) { - $this->itemHolderValidators[] = $itemHolderValidator; - } + $this->itemHolderValidators[] = $itemHolderValidator; } - public function addItemHolderPostValidator(ItemHolderPostValidator $itemHolderValidator) + public function addItemHolderPostValidator(ItemHolderPostValidator $itemHolderPostValidator) { - if (false === $this->containsProcessor($this->itemHolderPostValidators, $itemHolderValidator)) { - $this->itemHolderPostValidators[] = $itemHolderValidator; - } + $this->itemHolderPostValidators[] = $itemHolderPostValidator; } public function addDiscountProcessor(DiscountProcessor $discountProcessor) { - if (false === $this->containsProcessor($this->discountProcessors, $discountProcessor)) { - $this->discountProcessors[] = $discountProcessor; - } + $this->discountProcessors[] = $discountProcessor; } /** @@ -398,7 +384,7 @@ public function dump() return get_class($processor); }; $flows = [ - 0 => $this->flowType.' flow', + 0 => $this->flowType . ' flow', 'ItemValidator' => $this->itemValidators->map($callback)->toArray(), 'ItemHolderValidator' => $this->itemHolderValidators->map($callback)->toArray(), 'ItemPreprocessor' => $this->itemPreprocessors->map($callback)->toArray(), @@ -415,9 +401,9 @@ public function dump() $out = ''; foreach ($tree as $key => $value) { if (is_numeric($key)) { - $out .= $value.PHP_EOL; + $out .= $value . PHP_EOL; } else { - $out .= $key.PHP_EOL; + $out .= $key . PHP_EOL; } } @@ -431,17 +417,4 @@ public function __toString() { return $this->dump(); } - - /** - * @param ArrayCollection $processors - * @param $processor - * - * @return bool - */ - protected function containsProcessor(ArrayCollection $processors, $processor): bool - { - return $processors->filter(function ($proc) use ($processor) { - return get_class($proc) === get_class($processor); - })->count() > 0; - } } From d55f3b0940aef80c55b692539570db4dd3c49dcb Mon Sep 17 00:00:00 2001 From: kurozumi Date: Mon, 15 Apr 2024 08:57:41 +0900 Subject: [PATCH 21/21] fix typo --- app/config/eccube/packages/purchaseflow.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/config/eccube/packages/purchaseflow.yaml b/app/config/eccube/packages/purchaseflow.yaml index 9c57f69c168..32b96d7c040 100644 --- a/app/config/eccube/packages/purchaseflow.yaml +++ b/app/config/eccube/packages/purchaseflow.yaml @@ -140,7 +140,7 @@ services: - '@Eccube\Repository\Master\TaxDisplayTypeRepository' - '@Eccube\Repository\Master\TaxTypeRepository' tags: - - { name: eccube.item.holder.preprocessor, flow_type: shopping, priority: 500 } + - { name: eccube.item.holder.preprocessor, flow_type: shopping, priority: 600 } eccube.purchase.flow.item.holder.preprocessor.tax.processor.after: # 税額の計算(送料明細・手数料明細に対して税額を計算) class: Eccube\Service\PurchaseFlow\Processor\TaxProcessor @@ -150,7 +150,7 @@ services: - '@Eccube\Service\TaxRuleService' - '@Eccube\Service\OrderHelper' tags: - - { name: eccube.item.holder.preprocessor, flow_type: shopping, priority: 400 } + - { name: eccube.item.holder.preprocessor, flow_type: shopping, priority: 500 } # addDiscountProcessor eccube.purchase.flow.discount.processor.point.processor: @@ -218,7 +218,7 @@ services: - { name: eccube.item.holder.post.validator, flow_type: shopping, priority: 300 } # addPurchaseProcessor - eccybe.purchase.flow.purchase.processor.pre.order.id.validator: + eccube.purchase.flow.purchase.processor.pre.order.id.validator: class: Eccube\Service\PurchaseFlow\Processor\PreOrderIdValidator arguments: - '@Eccube\Service\CartService'