Skip to content

DI Extensions can not use parameters from app main configuration #309

@forgie1

Description

@forgie1

Version: 3.2.0

Bug Description

config/common.neon

parameters:
	secretDir: 'mySecretDir'

extensions:
	myDiExtension: Plugin\DIExtension

DIExtension class

...
class DIExtension extends CompilerExtension
{

	public function loadConfiguration()
	{
		$this->compiler->loadConfig(__DIR__ . '/di.neon');
	}

}

di.neon

services:
	- Plugin\MyService(%secretDir%)

Parameter secretDir is not exchanged (translated) with its value mySecretDir

Expected Behavior

Parameter secretDir will be "translated" to its value mySecretDir

Possible Solution

Load configs in \Nette\DI\Compiler::processExtensions() before running this $first extensions:

$first = $this->getExtensions(Extensions\ParametersExtension::class) + $this->getExtensions(Extensions\ExtensionsExtension::class);
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions