File tree Expand file tree Collapse file tree 5 files changed +26
-3
lines changed Expand file tree Collapse file tree 5 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -271,12 +271,16 @@ public function addClassResource(\ReflectionClass $class)
271271 * @throws BadMethodCallException When this ContainerBuilder is frozen
272272 * @throws \LogicException if the container is frozen
273273 */
274- public function loadFromExtension ($ extension , array $ values = array () )
274+ public function loadFromExtension ($ extension , array $ values = null )
275275 {
276276 if ($ this ->isFrozen ()) {
277277 throw new BadMethodCallException ('Cannot load from an extension on a frozen container. ' );
278278 }
279279
280+ if (func_num_args () < 2 ) {
281+ $ values = array ();
282+ }
283+
280284 $ namespace = $ this ->getExtension ($ extension )->getAlias ();
281285
282286 $ this ->extensionConfigs [$ namespace ][] = $ values ;
Original file line number Diff line number Diff line change @@ -425,7 +425,7 @@ private function loadFromExtensions(array $content)
425425 continue ;
426426 }
427427
428- if (!is_array ($ values )) {
428+ if (!is_array ($ values ) && null !== $ values ) {
429429 $ values = array ();
430430 }
431431
Original file line number Diff line number Diff line change @@ -8,7 +8,14 @@ class ProjectExtension implements ExtensionInterface
88{
99 public function load (array $ configs , ContainerBuilder $ configuration )
1010 {
11- $ config = call_user_func_array ('array_merge ' , $ configs );
11+ $ configuration ->setParameter ('project.configs ' , $ configs );
12+ $ configs = array_filter ($ configs );
13+
14+ if ($ configs ) {
15+ $ config = call_user_func_array ('array_merge ' , $ configs );
16+ } else {
17+ $ config = array ();
18+ }
1219
1320 $ configuration ->setDefinition ('project.service.bar ' , new Definition ('FooClass ' ));
1421 $ configuration ->setParameter ('project.parameter.bar ' , isset ($ config ['foo ' ]) ? $ config ['foo ' ] : 'foobar ' );
Original file line number Diff line number Diff line change 1+ project : ~
Original file line number Diff line number Diff line change @@ -207,6 +207,17 @@ public function testExtensions()
207207 }
208208 }
209209
210+ public function testExtensionWithNullConfig ()
211+ {
212+ $ container = new ContainerBuilder ();
213+ $ container ->registerExtension (new \ProjectExtension ());
214+ $ loader = new YamlFileLoader ($ container , new FileLocator (self ::$ fixturesPath .'/yaml ' ));
215+ $ loader ->load ('null_config.yml ' );
216+ $ container ->compile ();
217+
218+ $ this ->assertSame (array (null ), $ container ->getParameter ('project.configs ' ));
219+ }
220+
210221 public function testSupports ()
211222 {
212223 $ loader = new YamlFileLoader (new ContainerBuilder (), new FileLocator ());
You can’t perform that action at this time.
0 commit comments