|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Gacela\Framework\Bootstrap\Setup; |
|
6
|
|
|
|
|
7
|
|
|
use Gacela\Framework\Bootstrap\SetupGacela; |
|
8
|
|
|
|
|
9
|
|
|
use function array_merge; |
|
10
|
|
|
use function array_unique; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Merges individual properties into a SetupGacela instance. |
|
14
|
|
|
*/ |
|
15
|
|
|
final class PropertyMerger |
|
16
|
|
|
{ |
|
17
|
|
|
public function __construct( |
|
18
|
|
|
private readonly SetupGacela $setup, |
|
19
|
|
|
) { |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @param array<string,class-string|object|callable> $list |
|
24
|
|
|
*/ |
|
25
|
|
|
public function mergeExternalServices(array $list): void |
|
26
|
|
|
{ |
|
27
|
|
|
$current = $this->setup->externalServices(); |
|
28
|
|
|
$this->setup->setExternalServices(array_merge($current, $list)); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @param list<string> $list |
|
33
|
|
|
*/ |
|
34
|
|
|
public function mergeProjectNamespaces(array $list): void |
|
35
|
|
|
{ |
|
36
|
|
|
$current = $this->setup->getProjectNamespaces(); |
|
37
|
|
|
$this->setup->setProjectNamespaces(array_merge($current, $list)); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @param array<string,mixed> $list |
|
42
|
|
|
*/ |
|
43
|
|
|
public function mergeConfigKeyValues(array $list): void |
|
44
|
|
|
{ |
|
45
|
|
|
$current = $this->setup->getConfigKeyValues(); |
|
46
|
|
|
$this->setup->setConfigKeyValues(array_merge($current, $list)); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @param list<class-string> $list |
|
51
|
|
|
*/ |
|
52
|
|
|
public function mergeGacelaConfigsToExtend(array $list): void |
|
53
|
|
|
{ |
|
54
|
|
|
$current = $this->setup->getGacelaConfigsToExtend(); |
|
55
|
|
|
/** @var list<class-string> $merged */ |
|
56
|
|
|
$merged = array_values(array_unique(array_merge($current, $list))); |
|
57
|
|
|
$this->setup->setGacelaConfigsToExtend($merged); |
|
|
|
|
|
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @param list<class-string|callable> $list |
|
62
|
|
|
*/ |
|
63
|
|
|
public function mergePlugins(array $list): void |
|
64
|
|
|
{ |
|
65
|
|
|
$current = $this->setup->getPlugins(); |
|
66
|
|
|
$this->setup->setPlugins(array_merge($current, $list)); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|