diff --git a/src/DI/Extensions/ExtensionsExtension.php b/src/DI/Extensions/ExtensionsExtension.php index b6123702c..9c4b3874c 100644 --- a/src/DI/Extensions/ExtensionsExtension.php +++ b/src/DI/Extensions/ExtensionsExtension.php @@ -21,7 +21,12 @@ class ExtensionsExtension extends Nette\DI\CompilerExtension public function loadConfiguration() { foreach ($this->getConfig() as $name => $class) { - $this->compiler->addExtension($name, new $class); + if ($class instanceof \stdClass) { + $rc = Nette\Reflection\ClassType::from($class->value); + $this->compiler->addExtension($name, $rc->newInstanceArgs($class->attributes)); + } else { + $this->compiler->addExtension($name, new $class); + } } } diff --git a/tests/DI/Compiler.extension.extensions.phpt b/tests/DI/Compiler.extension.extensions.phpt index 1b34da498..8a1dc0578 100644 --- a/tests/DI/Compiler.extension.extensions.phpt +++ b/tests/DI/Compiler.extension.extensions.phpt @@ -20,11 +20,31 @@ class FooExtension extends DI\CompilerExtension } +class BarExtension extends DI\CompilerExtension +{ + private $param; + + public function __construct($param) + { + $this->param = $param; + } + + function loadConfiguration() + { + $this->getContainerBuilder()->parameters['bar'] = $this->param; + } +} + + $compiler = new DI\Compiler; $compiler->addExtension('extensions', new Nette\DI\Extensions\ExtensionsExtension); $container = createContainer($compiler, ' +parameters: + param: test + extensions: foo: FooExtension + bar: BarExtension(%param%) foo: key: value @@ -32,3 +52,4 @@ foo: Assert::same( 'hello', $container->parameters['foo'] ); +Assert::same( 'test', $container->parameters['bar'] );