diff --git a/src/DI/ContainerFactory.php b/src/DI/ContainerFactory.php index 3b6def28f..b30825f7e 100644 --- a/src/DI/ContainerFactory.php +++ b/src/DI/ContainerFactory.php @@ -32,7 +32,7 @@ class ContainerFactory extends Nette\Object /** @var array */ public $config = array(); - /** @var array [file, section] */ + /** @var array [file|array, section] */ public $configFiles = array(); /** @var string */ @@ -71,7 +71,9 @@ protected function generateCode() $code = "configFiles as $info) { - $code .= "// source: $info[0] $info[1]\n"; + if (is_scalar($info[0])) { + $code .= "// source: $info[0] $info[1]\n"; + } } $code .= "\n" . $compiler->compile($config, $this->class, $this->parentClass); @@ -90,7 +92,8 @@ protected function generateConfig() $config = array(); $loader = $this->createLoader(); foreach ($this->configFiles as $info) { - $config = Config\Helpers::merge($loader->load($info[0], $info[1]), $config); + $info = is_scalar($info[0]) ? $loader->load($info[0], $info[1]) : $info[0]; + $config = Config\Helpers::merge($info, $config); } $this->dependencies = array_merge($this->dependencies, $loader->getDependencies()); diff --git a/tests/DI/ContainerFactory.basic.phpt b/tests/DI/ContainerFactory.basic.phpt index c3aa304e7..bf12e665f 100644 --- a/tests/DI/ContainerFactory.basic.phpt +++ b/tests/DI/ContainerFactory.basic.phpt @@ -25,3 +25,12 @@ $factory->class = 'My'; $container = $factory->create(); Assert::type($factory->class, $container); Assert::type($factory->parentClass, $container); + +$factory->class = 'My2'; +$factory->config = array('parameters' => array('foo' => 'a')); +$factory->configFiles = array( + array(Tester\FileMock::create('parameters: {foo: b}', 'neon'), NULL), + array(array('parameters' => array('foo' => 'c')), NULL), +); +$container = $factory->create(); +Assert::same(array('foo' => 'c'), $container->parameters);