1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* Copyright (C) 2020-2025 Iain Cambridge |
7
|
|
|
* |
8
|
|
|
* This program is free software: you can redistribute it and/or modify |
9
|
|
|
* it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as published by |
10
|
|
|
* the Free Software Foundation, either version 2.1 of the License, or |
11
|
|
|
* (at your option) any later version. |
12
|
|
|
* |
13
|
|
|
* This program is distributed in the hope that it will be useful, |
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16
|
|
|
* GNU Lesser General Public License for more details. |
17
|
|
|
* |
18
|
|
|
* You should have received a copy of the GNU General Public License |
19
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
namespace Parthenon\DependencyInjection; |
23
|
|
|
|
24
|
|
|
use Parthenon\DependencyInjection\Modules\AbTesting; |
25
|
|
|
use Parthenon\DependencyInjection\Modules\Athena; |
26
|
|
|
use Parthenon\DependencyInjection\Modules\Billing; |
27
|
|
|
use Parthenon\DependencyInjection\Modules\Cloud; |
28
|
|
|
use Parthenon\DependencyInjection\Modules\Common; |
29
|
|
|
use Parthenon\DependencyInjection\Modules\Export; |
30
|
|
|
use Parthenon\DependencyInjection\Modules\Funnel; |
31
|
|
|
use Parthenon\DependencyInjection\Modules\Health; |
32
|
|
|
use Parthenon\DependencyInjection\Modules\Invoice; |
33
|
|
|
use Parthenon\DependencyInjection\Modules\MultiTenancy; |
34
|
|
|
use Parthenon\DependencyInjection\Modules\Notification; |
35
|
|
|
use Parthenon\DependencyInjection\Modules\Payments; |
36
|
|
|
use Parthenon\DependencyInjection\Modules\User; |
37
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
38
|
|
|
use Symfony\Component\DependencyInjection\Extension\Extension; |
39
|
|
|
|
40
|
|
|
class ParthenonExtension extends Extension |
41
|
|
|
{ |
42
|
|
|
public function load(array $configs, ContainerBuilder $container) |
43
|
|
|
{ |
44
|
|
|
$configuration = $this->getConfiguration($configs, $container); |
45
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
|
|
|
|
46
|
|
|
if (empty($config)) { |
47
|
|
|
return; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
$this->handleCommon($config, $container); |
51
|
|
|
$this->handleNotification($config, $container); |
52
|
|
|
$this->handleUserConfig($config, $container); |
53
|
|
|
$this->handleAthena($config, $container); |
54
|
|
|
$this->handleAbTesting($config, $container); |
55
|
|
|
$this->handleFunnelConfig($config, $container); |
56
|
|
|
$this->handleHealth($config, $container); |
57
|
|
|
$this->handleInvoice($config, $container); |
58
|
|
|
$this->handlePayments($config, $container); |
59
|
|
|
$this->handleMultiTenancy($config, $container); |
60
|
|
|
$this->handleCloud($config, $container); |
61
|
|
|
$this->handleExport($config, $container); |
62
|
|
|
$this->handleBilling($config, $container); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function handleFunnelConfig(array $config, ContainerBuilder $container) |
66
|
|
|
{ |
67
|
|
|
$funnel = new Funnel(); |
68
|
|
|
$funnel->handleDefaultParameters($container); |
69
|
|
|
$funnel->handleConfiguration($config, $container); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function handleUserConfig(array $config, ContainerBuilder $container) |
73
|
|
|
{ |
74
|
|
|
$user = new User(); |
75
|
|
|
$user->handleDefaultParameters($container); |
76
|
|
|
$user->handleConfiguration($config, $container); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public function handleCommon(array $config, ContainerBuilder $container) |
80
|
|
|
{ |
81
|
|
|
$common = new Common(); |
82
|
|
|
$common->handleDefaultParameters($container); |
83
|
|
|
$common->handleConfiguration($config, $container); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function handleNotification(array $config, ContainerBuilder $container) |
87
|
|
|
{ |
88
|
|
|
$notification = new Notification(); |
89
|
|
|
$notification->handleDefaultParameters($container); |
90
|
|
|
$notification->handleConfiguration($config, $container); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
public function handleAthena(array $config, ContainerBuilder $container) |
94
|
|
|
{ |
95
|
|
|
$athena = new Athena(); |
96
|
|
|
$athena->handleDefaultParameters($container); |
97
|
|
|
$athena->handleConfiguration($config, $container); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public function handleHealth(array $config, ContainerBuilder $container) |
101
|
|
|
{ |
102
|
|
|
$health = new Health(); |
103
|
|
|
$health->handleDefaultParameters($container); |
104
|
|
|
$health->handleConfiguration($config, $container); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
public function handleInvoice(array $config, ContainerBuilder $container) |
108
|
|
|
{ |
109
|
|
|
$invoice = new Invoice(); |
110
|
|
|
$invoice->handleDefaultParameters($container); |
111
|
|
|
$invoice->handleConfiguration($config, $container); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
public function handleAbTesting(array $config, ContainerBuilder $container) |
115
|
|
|
{ |
116
|
|
|
$abTesting = new AbTesting(); |
117
|
|
|
$abTesting->handleDefaultParameters($container); |
118
|
|
|
$abTesting->handleConfiguration($config, $container); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
public function handleBilling(array $config, ContainerBuilder $container) |
122
|
|
|
{ |
123
|
|
|
$export = new Billing(); |
124
|
|
|
$export->handleDefaultParameters($container); |
125
|
|
|
$export->handleConfiguration($config, $container); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
public function handleExport(array $config, ContainerBuilder $container) |
129
|
|
|
{ |
130
|
|
|
$export = new Export(); |
131
|
|
|
$export->handleDefaultParameters($container); |
132
|
|
|
$export->handleConfiguration($config, $container); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
private function handlePayments(array $config, ContainerBuilder $container) |
136
|
|
|
{ |
137
|
|
|
$payments = new Payments(); |
138
|
|
|
$payments->handleDefaultParameters($container); |
139
|
|
|
$payments->handleConfiguration($config, $container); |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
private function handleMultiTenancy(array $config, ContainerBuilder $container) |
143
|
|
|
{ |
144
|
|
|
$multiTenancy = new MultiTenancy(); |
145
|
|
|
$multiTenancy->handleDefaultParameters($container); |
146
|
|
|
$multiTenancy->handleConfiguration($config, $container); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
private function handleCloud(array $config, ContainerBuilder $container) |
150
|
|
|
{ |
151
|
|
|
$cloud = new Cloud(); |
152
|
|
|
$cloud->handleDefaultParameters($container); |
153
|
|
|
$cloud->handleConfiguration($config, $container); |
154
|
|
|
} |
155
|
|
|
} |
156
|
|
|
|