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.bpm.variables.api_url', |
36
|
|
|
'value' => 'api_url' |
37
|
|
|
], |
38
|
|
|
[ |
39
|
|
|
'key' => 'app.bpm.variables.api_user', |
40
|
|
|
'value' => 'api_user' |
41
|
|
|
], |
42
|
|
|
[ |
43
|
|
|
'key' => 'app.bpm.variables.api_key', |
44
|
|
|
'value' => 'api_key' |
45
|
|
|
], |
46
|
|
|
[ |
47
|
|
|
'key' => 'app.bpm.variables.service_uuid', |
48
|
|
|
'value' => 'service_uuid' |
49
|
|
|
], |
50
|
|
|
[ |
51
|
|
|
'key' => 'app.bpm.variables.scenario_uuid', |
52
|
|
|
'value' => 'scenario_uuid' |
53
|
|
|
], |
54
|
|
|
[ |
55
|
|
|
'key' => 'app.bpm.variables.scenario_custom_data', |
56
|
|
|
'value' => 'scenario_custom_data' |
57
|
|
|
], |
58
|
|
|
[ |
59
|
|
|
'key' => 'app.bpm.variables.identity', |
60
|
|
|
'value' => 'identity' |
61
|
|
|
], |
62
|
|
|
[ |
63
|
|
|
'key' => 'app.bpm.variables.identity_uuid', |
64
|
|
|
'value' => 'identity_uuid' |
65
|
|
|
], |
66
|
|
|
[ |
67
|
|
|
'key' => 'app.bpm.variables.submission_uuid', |
68
|
|
|
'value' => 'submission_uuid' |
69
|
|
|
], |
70
|
|
|
[ |
71
|
|
|
'key' => 'app.bpm.variables.start_data', |
72
|
|
|
'value' => 'start_data' |
73
|
|
|
] |
74
|
|
|
]; |
75
|
|
|
|
76
|
|
|
$manager = $this->configService->getManager(); |
77
|
|
|
|
78
|
|
|
foreach ($items as $item) { |
79
|
|
|
$config = $this->configService->createInstance(); |
80
|
|
|
$config |
81
|
|
|
->setOwner('BusinessUnit') |
82
|
|
|
->setOwnerUuid($data['business_unit']['administration']['uuid']) |
83
|
|
|
->setKey($item['key']) |
84
|
|
|
->setValue($item['value']) |
85
|
|
|
->setTenant($data['tenant']['uuid']); |
86
|
|
|
$manager->persist($config); |
87
|
|
|
$manager->flush(); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|