File tree 3 files changed +9
-14
lines changed
3 files changed +9
-14
lines changed Original file line number Diff line number Diff line change @@ -146,6 +146,9 @@ public function has($id): bool
146
146
return true ;
147
147
}
148
148
149
+ /**
150
+ * @deprecated
151
+ */
149
152
public function getDefinitionSource (): Definition \DefinitionSourceInterface
150
153
{
151
154
return $ this ->definitionSource ;
Original file line number Diff line number Diff line change 16
16
17
17
class DefinitionSourceFactory
18
18
{
19
- protected string $ baseUri ;
20
-
21
- public function __construct (protected bool $ enableCache = false )
19
+ public function __invoke (): DefinitionSource
22
20
{
23
21
if (! defined ('BASE_PATH ' )) {
24
22
throw new Exception ('BASE_PATH is not defined. ' );
25
23
}
26
24
27
- $ this ->baseUri = BASE_PATH ;
28
- }
29
-
30
- public function __invoke ()
31
- {
32
- $ configDir = $ this ->baseUri . '/config ' ;
33
-
34
25
$ configFromProviders = [];
35
26
if (class_exists (ProviderConfig::class)) {
36
27
$ configFromProviders = ProviderConfig::load ();
37
28
}
38
29
39
30
$ serverDependencies = $ configFromProviders ['dependencies ' ] ?? [];
40
- if (file_exists ($ configDir . '/autoload/dependencies.php ' )) {
41
- $ definitions = include $ configDir . '/autoload/dependencies.php ' ;
31
+ $ dependenciesPath = BASE_PATH . '/config/autoload/dependencies.php ' ;
32
+ if (file_exists ($ dependenciesPath )) {
33
+ $ definitions = include $ dependenciesPath ;
42
34
$ serverDependencies = array_replace ($ serverDependencies , $ definitions ?? []);
43
35
}
44
36
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ class DefinitionSourceTest extends TestCase
26
26
public function testAddDefinition ()
27
27
{
28
28
$ container = new Container (new DefinitionSource ([]));
29
- $ container ->getDefinitionSource ()-> addDefinition ('Foo ' , function () {
29
+ $ container ->define ('Foo ' , function () {
30
30
return 'bar ' ;
31
31
});
32
32
$ this ->assertEquals ('bar ' , $ container ->get ('Foo ' ));
@@ -35,7 +35,7 @@ public function testAddDefinition()
35
35
public function testDefinitionFactory ()
36
36
{
37
37
$ container = new Container (new DefinitionSource ([]));
38
- $ container ->getDefinitionSource ()-> addDefinition ('Foo ' , FooFactory::class);
38
+ $ container ->define ('Foo ' , FooFactory::class);
39
39
40
40
$ foo = $ container ->get ('Foo ' );
41
41
$ this ->assertInstanceOf (Foo::class, $ foo );
You can’t perform that action at this time.
0 commit comments