From 4a7d085504cd100dfee2d8e37e6e8910e1c837b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BE=BB=20=E6=8B=93=E4=B9=9F?= Date: Mon, 29 Jul 2024 15:37:54 +0900 Subject: [PATCH] =?UTF-8?q?PurchaseFlow=E3=81=AEPriority=E3=81=8C=E6=84=8F?= =?UTF-8?q?=E5=9B=B3=E3=81=97=E3=81=AA=E3=81=84=E3=82=BD=E3=83=BC=E3=83=88?= =?UTF-8?q?=E9=A0=86=E3=81=AB=E3=81=AA=E3=81=A3=E3=81=A6=E3=81=84=E3=82=8B?= =?UTF-8?q?=E5=A0=B4=E5=90=88=E3=81=8C=E3=81=82=E3=82=8B=20#6257=20?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3=20purchaseFlow=E3=81=A7=E5=91=BC?= =?UTF-8?q?=E3=81=B3=E5=87=BA=E3=81=99=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89?= =?UTF-8?q?=E3=81=8CflowType=E3=81=94=E3=81=A8=E3=81=AB=E3=82=BD=E3=83=BC?= =?UTF-8?q?=E3=83=88=E3=81=95=E3=82=8C=E3=81=A6=E3=81=84=E3=81=AA=E3=81=8B?= =?UTF-8?q?=E3=81=A3=E3=81=9F=E3=81=9F=E3=82=81=E3=80=81flowType=E3=81=94?= =?UTF-8?q?=E3=81=A8=E3=81=AB=E3=82=BD=E3=83=BC=E3=83=88=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Compiler/PurchaseFlowPass.php | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php b/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php index a01bf5c2b1..c8215ed443 100644 --- a/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php +++ b/src/Eccube/DependencyInjection/Compiler/PurchaseFlowPass.php @@ -50,19 +50,32 @@ public function process(ContainerBuilder $container) */ foreach ($this->getProcessorTags() as $tag => $methodName) { /** @var Reference $id */ + $allMethod = []; + $i = 0; + // findAndSortTaggedServicesでは、flow_typeごとのソートができないため + // その並びをもとに配列に入れ直す 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, [$id]); - } - } + $attributes['id'] = $id; + $attributes['index'] = ++$i; + $attributes['priority'] = isset($attributes['priority']) ? $attributes['priority'] : 0; + $allMethod[$attributes['flow_type']][] = $attributes; + } + } + } + /** + * @var string $flowType + * @var Definition $purchaseFlowDef + */ + foreach ($allMethod as $flowType => $flowMethod) { + $purchaseFlowDef = isset($flowTypes[$flowType]) ? $flowTypes[$flowType] : null; ; + if (!is_null($purchaseFlowDef) && count($flowMethod) > 0) { + // flow_typeごとにソートをしてセットする + uasort($flowMethod, static fn ($a, $b) => $b['priority'] <=> $a['priority'] ? : $a['index'] <=> $b['index']); + foreach ($flowMethod as $attributes) { + $purchaseFlowDef->addMethodCall($methodName, [$attributes['id']]); } } }