|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Gacela\Framework; |
|
6
|
|
|
|
|
7
|
|
|
use Gacela\Framework\Config\ConfigReaderInterface; |
|
8
|
|
|
|
|
9
|
|
|
abstract class AbstractConfigGacela |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* e.g: |
|
13
|
|
|
* <code> |
|
14
|
|
|
* return [ |
|
15
|
|
|
* 'path' => '.env*', |
|
16
|
|
|
* 'path_local' => '.env', |
|
17
|
|
|
* ]; |
|
18
|
|
|
* # OR |
|
19
|
|
|
* return [ |
|
20
|
|
|
* [ |
|
21
|
|
|
* 'path' => '.env*', |
|
22
|
|
|
* 'path_local' => '.env', |
|
23
|
|
|
* ], |
|
24
|
|
|
* [ |
|
25
|
|
|
* 'path' => 'config/*.php', |
|
26
|
|
|
* 'path_local' => 'config/local.php', |
|
27
|
|
|
* ], |
|
28
|
|
|
* ]; |
|
29
|
|
|
* </code> |
|
30
|
|
|
* |
|
31
|
|
|
* <b>path</b>: Define the path where Gacela will read all the config files. Default: <i>config/*.php</i><br> |
|
32
|
|
|
* <b>path_local</b>: Define the path where Gacela will read the local config file. Default: <i>config/local.php</i> |
|
33
|
|
|
* |
|
34
|
|
|
* @return array<array>|array{ |
|
|
|
|
|
|
35
|
|
|
* path?:string, |
|
36
|
|
|
* path_local?:string |
|
37
|
|
|
* } |
|
38
|
|
|
*/ |
|
39
|
6 |
|
public function config(): array |
|
40
|
|
|
{ |
|
41
|
6 |
|
return []; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* e.g: |
|
46
|
|
|
* <code> |
|
47
|
|
|
* return [ |
|
48
|
|
|
* 'php' => new \Gacela\Framework\Config\ConfigReader\PhpConfigReader(), |
|
49
|
|
|
* ]; |
|
50
|
|
|
* </code> |
|
51
|
|
|
* |
|
52
|
|
|
* Define the reader class which will read and parse the config files. Default: <i>PhpConfigReader</i> |
|
53
|
|
|
* |
|
54
|
|
|
* @return array<string,ConfigReaderInterface> |
|
55
|
|
|
*/ |
|
56
|
7 |
|
public function configReaders(): array |
|
57
|
|
|
{ |
|
58
|
7 |
|
return []; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* e.g: |
|
63
|
|
|
* <code> |
|
64
|
|
|
* return [ |
|
65
|
|
|
* // It instantiates the specific class on runtime |
|
66
|
|
|
* AbstractClass::class => SpecificClass::class, |
|
67
|
|
|
* |
|
68
|
|
|
* // It resolves the callable on runtime |
|
69
|
|
|
* InterfaceClass::class => fn() => new SpecificClass($dependencies), |
|
70
|
|
|
* ]; |
|
71
|
|
|
* </code> |
|
72
|
|
|
* |
|
73
|
|
|
* Define the mapping between interfaces and concretions, so Gacela services will auto-resolve them automatically. |
|
74
|
|
|
* |
|
75
|
|
|
* @param array<string,mixed> $globalServices |
|
76
|
|
|
* |
|
77
|
|
|
* @return array<class-string,class-string|callable> |
|
78
|
|
|
*/ |
|
79
|
1 |
|
public function mappingInterfaces(array $globalServices): array |
|
80
|
|
|
{ |
|
81
|
1 |
|
return []; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* e.g: |
|
86
|
|
|
* <code> |
|
87
|
|
|
* return [ |
|
88
|
|
|
* 'Application', |
|
89
|
|
|
* 'Infrastructure\Persistence', |
|
90
|
|
|
* ]; |
|
91
|
|
|
* </code> |
|
92
|
|
|
* |
|
93
|
|
|
* Define namespaces (relative to a module) where Gacela should check for custom services that will be auto-resolved. |
|
94
|
|
|
* The classes that you want to use as custom services must extend `Gacela\Framework\AbstractCustomService`. |
|
95
|
|
|
* |
|
96
|
|
|
* @return list<string> |
|
97
|
|
|
*/ |
|
98
|
7 |
|
public function customServicesLocation(): array |
|
99
|
|
|
{ |
|
100
|
7 |
|
return []; |
|
101
|
|
|
} |
|
102
|
|
|
} |
|
103
|
|
|
|