1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AppBundle\Tenant\Initializer; |
4
|
|
|
|
5
|
|
|
use Ds\Component\Config\Service\ConfigService; |
6
|
|
|
use Ds\Component\Tenant\Initializer\Initializer; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class ConfigInitializer |
10
|
|
|
*/ |
11
|
|
|
class ConfigInitializer implements Initializer |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @var \Ds\Component\Config\Service\ConfigService |
15
|
|
|
*/ |
16
|
|
|
protected $configService; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Constructor |
20
|
|
|
* |
21
|
|
|
* @param \Ds\Component\Config\Service\ConfigService $configService |
22
|
|
|
*/ |
23
|
|
|
public function __construct(ConfigService $configService) |
24
|
|
|
{ |
25
|
|
|
$this->configService = $configService; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* {@inheritdoc} |
30
|
|
|
*/ |
31
|
|
|
public function initialize(array $data) |
32
|
|
|
{ |
33
|
|
|
$items = [ |
34
|
|
|
[ |
35
|
|
|
'key' => 'app.spa.admin', |
36
|
|
|
'value' => $data['config']['app.spa.admin']['value'] |
37
|
|
|
], |
38
|
|
|
[ |
39
|
|
|
'key' => 'app.spa.portal', |
40
|
|
|
'value' => $data['config']['app.spa.portal']['value'] |
41
|
|
|
], |
42
|
|
|
[ |
43
|
|
|
'key' => 'app.registration.individual.owner', |
44
|
|
|
'value' => 'BusinessUnit' |
45
|
|
|
], |
46
|
|
|
[ |
47
|
|
|
'key' => 'app.registration.individual.owner_uuid', |
48
|
|
|
'value' => $data['business_unit']['administration']['uuid'] |
49
|
|
|
], |
50
|
|
|
[ |
51
|
|
|
'key' => 'app.registration.individual.roles', |
52
|
|
|
'value' => 'ROLE_INDIVIDUAL' |
53
|
|
|
], |
54
|
|
|
[ |
55
|
|
|
'key' => 'app.registration.individual.enabled', |
56
|
|
|
'value' => '1' |
57
|
|
|
], |
58
|
|
|
[ |
59
|
|
|
'key' => 'app.registration.organization.owner', |
60
|
|
|
'value' => 'BusinessUnit' |
61
|
|
|
], |
62
|
|
|
[ |
63
|
|
|
'key' => 'app.registration.organization.owner_uuid', |
64
|
|
|
'value' => $data['business_unit']['administration']['uuid'] |
65
|
|
|
], |
66
|
|
|
[ |
67
|
|
|
'key' => 'app.registration.organization.roles', |
68
|
|
|
'value' => 'ROLE_ORGANIZATION' |
69
|
|
|
], |
70
|
|
|
[ |
71
|
|
|
'key' => 'app.registration.organization.enabled', |
72
|
|
|
'value' => '1' |
73
|
|
|
], |
74
|
|
|
[ |
75
|
|
|
'key' => 'app.resetting.email.subject', |
76
|
|
|
'value' => 'app.resetting.email.subject' |
77
|
|
|
], |
78
|
|
|
[ |
79
|
|
|
'key' => 'app.resetting.email.body.plain', |
80
|
|
|
'value' => 'app.resetting.email.body.plain' |
81
|
|
|
], |
82
|
|
|
[ |
83
|
|
|
'key' => 'app.resetting.email.body.html', |
84
|
|
|
'value' => 'app.resetting.email.body.html' |
85
|
|
|
] |
86
|
|
|
]; |
87
|
|
|
|
88
|
|
|
$manager = $this->configService->getManager(); |
89
|
|
|
|
90
|
|
|
foreach ($items as $item) { |
91
|
|
|
$config = $this->configService->createInstance(); |
92
|
|
|
$config |
93
|
|
|
->setOwner('BusinessUnit') |
94
|
|
|
->setOwnerUuid($data['business_unit']['administration']['uuid']) |
95
|
|
|
->setKey($item['key']) |
96
|
|
|
->setValue($item['value']) |
97
|
|
|
->setTenant($data['tenant']['uuid']); |
98
|
|
|
$manager->persist($config); |
99
|
|
|
$manager->flush(); |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
|