laminas / laminas-component-installer

Composer plugin for injecting modules and configuration providers into application configuration
https://docs.laminas.dev/laminas-component-installer/
BSD 3-Clause "New" or "Revised" License
27 stars 12 forks source link

ConfigProvider Injection does not work when multiple ConfigAggregator instances are available #21

Closed boesing closed 3 years ago

boesing commented 3 years ago

Bug Report

Q A
Version(s) 2.3.2

Summary

I am using the component installer in a project where I also use parameters for multiple environments. Thus, I have the following config.php:

return (new ConfigAggregator([
    MyModule\ConfigProvider::class,
], null, [
    new LazyParameterPostProcessor(static function (): array {
        return (new ConfigAggregator([
            new PhpFileProvider(sprintf(
                '%s/parameters{,*.}{,%s,local}.php',
                __DIR__,
                'someenvironment'
            )),
        ]))->getMergedConfig();
    }),
]))->getMergedConfig();

This will actually do the following:

  1. Merge all config providers
  2. Post-process configuration by executing the LazyParameterPostProcessor
  3. Load all parameters files from I/O with the name(s) (in that order): 3.1 parameters.php 3.2 parameters.someenvironment.php 3.3 parameters.local.php

Current behavior

A new config provider is being added to the callable of LazyParameterPostProcessor as there is another ConfigAggregator instance.

How to reproduce

Use configuration above for reproducibility.

Expected behavior

Add the new config provider to the first appearance of a ConfigAggregator.