nette / bootstrap

🅱 The simple way to configure and bootstrap your Nette application.
https://doc.nette.org/bootstrap
Other
668 stars 36 forks source link

Configurator: unable to overwrite parameters set by addConfig by calling addParameters #45

Closed janedbal closed 8 years ago

janedbal commented 8 years ago

Following code will echo number 2 which is very confusing.

require __DIR__ . '/vendor/autoload.php';

$configurator = new Nette\Configurator();
$configurator->setTempDirectory(__DIR__ . '/temp');

$configurator->addParameters(['test' => '1']);
$configurator->addConfig(__DIR__ . '/test.neon'); // parameters: test: 2
$configurator->addParameters(['test' => '3']);

$container = $configurator->createContainer();
echo $container->getParameters()['test'];
dg commented 8 years ago

Can you prepare test?

janedbal commented 8 years ago

What do you mean? Send PR with failing test?

dg commented 8 years ago

Exactly

janedbal commented 8 years ago

Done.

dg commented 8 years ago

I don't want to introduce BC break, but there is simple workaround:

$configurator->addConfig(['parameters' => ['test' => '1']]);
$configurator->addConfig(__DIR__ . '/test.neon'); // parameters: test: 2
$configurator->addConfig(['parameters' => ['test' => '3']]);