|
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 Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
|
17
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* プラグインのコンポーネント定義を制御するクラス. |
|
21
|
|
|
*/ |
|
22
|
|
|
class PluginPass implements CompilerPassInterface |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* プラグインのコンポーネント定義を制御する. |
|
26
|
|
|
* |
|
27
|
|
|
* 無効状態のプラグインに対し, 付与されているサービスタグをクリアすることで, |
|
28
|
|
|
* プラグインが作成しているEventListener等の拡張機構が呼び出されないようにする. |
|
29
|
|
|
* |
|
30
|
|
|
* サービスタグが収集されるタイミング(一般的にPassConfig::TYPE_BEFORE_OPTIMIZATIONの0)より先に実行される必要があります. |
|
31
|
|
|
* |
|
32
|
|
|
* @param ContainerBuilder $container |
|
33
|
|
|
*/ |
|
34
|
3 |
|
public function process(ContainerBuilder $container) |
|
35
|
|
|
{ |
|
36
|
|
|
// 無効状態のプラグインコード一覧を取得. |
|
37
|
|
|
// 無効なプラグインの一覧はEccubeExtensionで定義している. |
|
38
|
3 |
|
$plugins = $container->getParameter('eccube.plugins.disabled'); |
|
39
|
|
|
|
|
40
|
3 |
|
if (empty($plugins)) { |
|
41
|
1 |
|
$container->log($this, 'disabled plugins not found.'); |
|
42
|
|
|
|
|
43
|
1 |
|
return; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
2 |
|
$definitions = $container->getDefinitions(); |
|
47
|
|
|
|
|
48
|
2 |
|
foreach ($definitions as $definition) { |
|
49
|
2 |
|
$class = $definition->getClass(); |
|
50
|
|
|
|
|
51
|
2 |
|
foreach ($plugins as $plugin) { |
|
52
|
2 |
|
$namespace = 'Plugin\\'.$plugin.'\\'; |
|
53
|
|
|
|
|
54
|
2 |
|
if (false !== \strpos($class, $namespace)) { |
|
55
|
2 |
|
foreach ($definition->getTags() as $tag => $attr) { |
|
56
|
|
|
// PluginManagerからレポジトリを取得する場合があるため, |
|
57
|
|
|
// doctrine.repository_serviceタグはスキップする. |
|
58
|
2 |
|
if ($tag === 'doctrine.repository_service') { |
|
59
|
|
|
continue; |
|
60
|
|
|
} |
|
61
|
2 |
|
$definition->clearTag($tag); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|