File tree Expand file tree Collapse file tree 2 files changed +6
-15
lines changed Expand file tree Collapse file tree 2 files changed +6
-15
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ class Kernel
22
22
*
23
23
* @var string|null
24
24
*/
25
- private $ puliFactoryClass ;
25
+ public static $ puliFactoryClass ;
26
26
27
27
/**
28
28
* @var string[]
@@ -52,12 +52,12 @@ public function __construct(array $modules = [], $environment = 'prod')
52
52
*/
53
53
public function createContainer ()
54
54
{
55
- if (!$ this -> puliFactoryClass && !defined ('PULI_FACTORY_CLASS ' )) {
55
+ if (!self :: $ puliFactoryClass && !defined ('PULI_FACTORY_CLASS ' )) {
56
56
throw new \RuntimeException ('Puli is not installed ' );
57
57
}
58
58
59
59
// Create Puli objects
60
- $ factoryClass = $ this -> puliFactoryClass ?: PULI_FACTORY_CLASS ;
60
+ $ factoryClass = self :: $ puliFactoryClass ?: PULI_FACTORY_CLASS ;
61
61
$ factory = new $ factoryClass ();
62
62
/** @var ResourceRepository $repository */
63
63
$ repository = $ factory ->createRepository ();
@@ -86,14 +86,6 @@ public function createContainer()
86
86
return $ containerBuilder ->build ();
87
87
}
88
88
89
- /**
90
- * @param string $class
91
- */
92
- public function setPuliFactoryClass ($ class )
93
- {
94
- $ this ->puliFactoryClass = $ class ;
95
- }
96
-
97
89
/**
98
90
* Override this method to configure the cache to use for container definitions.
99
91
*
Original file line number Diff line number Diff line change @@ -22,9 +22,10 @@ public function setUp()
22
22
PuliFactoryClass::$ repository = new InMemoryRepository ();
23
23
PuliFactoryClass::$ discovery = new InMemoryDiscovery ();
24
24
25
- $ this ->kernel = new Kernel ();
26
25
// Mock the Puli factory
27
- $ this ->kernel ->setPuliFactoryClass (PuliFactoryClass::class);
26
+ Kernel::$ puliFactoryClass = PuliFactoryClass::class;
27
+
28
+ $ this ->kernel = new Kernel ();
28
29
}
29
30
30
31
/**
@@ -63,7 +64,6 @@ public function loads_module_configs()
63
64
$ this ->kernel = new Kernel ([
64
65
'blog ' ,
65
66
]);
66
- $ this ->kernel ->setPuliFactoryClass (PuliFactoryClass::class);
67
67
$ container = $ this ->kernel ->createContainer ();
68
68
69
69
$ this ->assertEquals ('bar ' , $ container ->get ('foo ' ));
@@ -80,7 +80,6 @@ public function loads_module_environment_config()
80
80
$ this ->kernel = new Kernel ([
81
81
'blog ' ,
82
82
], 'dev ' );
83
- $ this ->kernel ->setPuliFactoryClass (PuliFactoryClass::class);
84
83
$ container = $ this ->kernel ->createContainer ();
85
84
86
85
$ this ->assertEquals ('biz ' , $ container ->get ('foo ' ));
You can’t perform that action at this time.
0 commit comments