|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of EC-CUBE |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright(c) LOCKON CO.,LTD. All Rights Reserved. |
|
7
|
|
|
* |
|
8
|
|
|
* http://www.lockon.co.jp/ |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
11
|
|
|
* file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Eccube\DependencyInjection\Compiler; |
|
15
|
|
|
|
|
16
|
|
|
use Doctrine\Common\Annotations\AnnotationReader; |
|
17
|
|
|
use Doctrine\Common\Annotations\AnnotationRegistry; |
|
18
|
|
|
use Eccube\Annotation\CartFlow; |
|
19
|
|
|
use Eccube\Annotation\OrderFlow; |
|
20
|
|
|
use Eccube\Annotation\ShoppingFlow; |
|
21
|
|
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
|
22
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
23
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
|
24
|
|
|
|
|
25
|
|
|
class PurchaseFlowPass implements CompilerPassInterface |
|
|
|
|
|
|
26
|
|
|
{ |
|
27
|
|
|
const ITEM_PREPROCESSOR_TAG = 'eccube.item.preprocessor'; |
|
28
|
|
|
const ITEM_VALIDATOR_TAG = 'eccube.item.validator'; |
|
29
|
|
|
const ITEM_HOLDER_PREPROCESSOR_TAG = 'eccube.item.holder.preprocessor'; |
|
30
|
|
|
const ITEM_HOLDER_VALIDATOR_TAG = 'eccube.item.holder.validator'; |
|
31
|
|
|
const PURCHASE_PROCESSOR_TAG = 'eccube.purchase.processor'; |
|
32
|
|
|
|
|
33
|
9 |
|
public function process(ContainerBuilder $container) |
|
34
|
|
|
{ |
|
35
|
|
|
$flowDefs = [ |
|
36
|
9 |
|
CartFlow::class => $container->getDefinition('eccube.purchase.flow.cart'), |
|
37
|
9 |
|
ShoppingFlow::class => $container->getDefinition('eccube.purchase.flow.shopping'), |
|
38
|
9 |
|
OrderFlow::class => $container->getDefinition('eccube.purchase.flow.order'), |
|
39
|
|
|
]; |
|
40
|
|
|
|
|
41
|
|
|
$processorTags = [ |
|
42
|
9 |
|
self::ITEM_PREPROCESSOR_TAG => 'addItemPreprocessor', |
|
43
|
9 |
|
self::ITEM_VALIDATOR_TAG => 'addItemValidator', |
|
44
|
9 |
|
self::ITEM_HOLDER_PREPROCESSOR_TAG => 'addItemHolderPreprocessor', |
|
45
|
9 |
|
self::ITEM_HOLDER_VALIDATOR_TAG => 'addItemHolderValidator', |
|
46
|
9 |
|
self::PURCHASE_PROCESSOR_TAG => 'addPurchaseProcessor', |
|
47
|
|
|
]; |
|
48
|
|
|
|
|
49
|
9 |
|
AnnotationRegistry::registerAutoloadNamespace('Eccube\Annotation', __DIR__.'/../../../../src'); |
|
50
|
9 |
|
$reader = new AnnotationReader(); |
|
51
|
|
|
|
|
52
|
9 |
|
foreach ($processorTags as $tag => $methodName) { |
|
53
|
9 |
|
$ids = $container->findTaggedServiceIds($tag); |
|
54
|
9 |
|
foreach ($ids as $id => $tags) { |
|
55
|
9 |
|
$def = $container->getDefinition($id); |
|
56
|
9 |
|
foreach ($flowDefs as $annotationName => $purchaseFlowDef) { |
|
57
|
9 |
|
$anno = $reader->getClassAnnotation(new \ReflectionClass($def->getClass()), $annotationName); |
|
|
|
|
|
|
58
|
9 |
|
if ($anno) { |
|
59
|
9 |
|
$purchaseFlowDef->addMethodCall($methodName, [new Reference($id)]); |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|