|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Gacela\Framework\Bootstrap; |
|
6
|
|
|
|
|
7
|
|
|
use Gacela\Framework\ClassResolver\Cache\GacelaFileCache; |
|
8
|
|
|
use Gacela\Framework\Config\GacelaConfigBuilder\AppConfigBuilder; |
|
9
|
|
|
use Gacela\Framework\Config\GacelaConfigBuilder\BindingsBuilder; |
|
10
|
|
|
use Gacela\Framework\Config\GacelaConfigBuilder\SuffixTypesBuilder; |
|
11
|
|
|
|
|
12
|
|
|
abstract class AbstractSetupGacela implements SetupGacelaInterface |
|
13
|
|
|
{ |
|
14
|
|
|
public const shouldResetInMemoryCache = 'shouldResetInMemoryCache'; |
|
15
|
|
|
|
|
16
|
|
|
public const fileCacheEnabled = 'fileCacheEnabled'; |
|
17
|
|
|
|
|
18
|
|
|
public const fileCacheDirectory = 'fileCacheDirectory'; |
|
19
|
|
|
|
|
20
|
|
|
public const externalServices = 'externalServices'; |
|
21
|
|
|
|
|
22
|
|
|
public const projectNamespaces = 'projectNamespaces'; |
|
23
|
|
|
|
|
24
|
|
|
public const configKeyValues = 'configKeyValues'; |
|
25
|
|
|
|
|
26
|
|
|
public const servicesToExtend = 'servicesToExtend'; |
|
27
|
|
|
|
|
28
|
|
|
public const plugins = 'plugins'; |
|
29
|
|
|
|
|
30
|
|
|
public const gacelaConfigsToExtend = 'gacelaConfigsToExtend'; |
|
31
|
|
|
|
|
32
|
|
|
protected const DEFAULT_ARE_EVENT_LISTENERS_ENABLED = true; |
|
33
|
|
|
|
|
34
|
|
|
protected const DEFAULT_SHOULD_RESET_IN_MEMORY_CACHE = false; |
|
35
|
|
|
|
|
36
|
|
|
protected const DEFAULT_FILE_CACHE_ENABLED = GacelaFileCache::DEFAULT_ENABLED_VALUE; |
|
37
|
|
|
|
|
38
|
|
|
protected const DEFAULT_FILE_CACHE_DIRECTORY = GacelaFileCache::DEFAULT_DIRECTORY_VALUE; |
|
39
|
|
|
|
|
40
|
|
|
protected const DEFAULT_PROJECT_NAMESPACES = []; |
|
41
|
|
|
|
|
42
|
|
|
protected const DEFAULT_CONFIG_KEY_VALUES = []; |
|
43
|
|
|
|
|
44
|
|
|
protected const DEFAULT_GENERIC_LISTENERS = []; |
|
45
|
|
|
|
|
46
|
|
|
protected const DEFAULT_SPECIFIC_LISTENERS = []; |
|
47
|
|
|
|
|
48
|
|
|
protected const DEFAULT_SERVICES_TO_EXTEND = []; |
|
49
|
|
|
|
|
50
|
|
|
protected const DEFAULT_GACELA_CONFIGS_TO_EXTEND = []; |
|
51
|
|
|
|
|
52
|
|
|
protected const DEFAULT_PLUGINS = []; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Define different config sources. |
|
56
|
|
|
*/ |
|
57
|
|
|
public function buildAppConfig(AppConfigBuilder $builder): AppConfigBuilder |
|
58
|
|
|
{ |
|
59
|
|
|
return $builder; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Define the mapping between interfaces and concretions, so Gacela services will auto-resolve them automatically. |
|
64
|
|
|
* |
|
65
|
|
|
* @param array<string, class-string|object|callable> $externalServices |
|
66
|
|
|
*/ |
|
67
|
|
|
public function buildBindings(BindingsBuilder $builder, array $externalServices): BindingsBuilder |
|
68
|
|
|
{ |
|
69
|
|
|
return $builder; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Allow overriding gacela resolvable types. |
|
74
|
|
|
*/ |
|
75
|
|
|
public function buildSuffixTypes(SuffixTypesBuilder $builder): SuffixTypesBuilder |
|
76
|
|
|
{ |
|
77
|
|
|
return $builder; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @return array<string, class-string|object|callable> |
|
82
|
|
|
*/ |
|
83
|
|
|
public function externalServices(): array |
|
84
|
|
|
{ |
|
85
|
|
|
return []; |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
|