zendframework/zend-config-aggregator-parameters

PostProcessor extension for zendframework/zend-config-aggregator to allow usage of templated parameters within your configuration

1.0.0 2018-04-04 20:21 UTC

README

Build Status Coverage Status

Provides an extension to the zendframework/zend-config-aggregator to allow parameters within your configuration.

Usage

use Zend\ConfigAggregator\ArrayProvider;
use Zend\ConfigAggregator\ConfigAggregator;
use Zend\ConfigAggregatorParameters\ParameterPostProcessor;

$aggregator = new ConfigAggregator(
    [
        new ArrayProvider([
            'parameter_usage' => '%foo%',
            'parameter_name' => '%%foo%%',
            'recursive_parameter_usage' => '%bar.baz%',
        ]),
    ],
    null,
    [
        new ParameterPostProcessor([
            'foo' => 'bar',
            'bar' => [
                'baz' => 'qoo',
            ],
        ]),
    ]
);

var_dump($aggregator->getMergedConfig());

Result:

array(3) {
  'parameter_usage' =>
  string(3) "bar"
  'parameter_name' =>
  string(5) "%foo%"
  'recursive_parameter_usage' =>
  string(3) "qoo"
  'parameters' =>
  array(3) {
    'foo' => 
     string(3) "bar"
    'bar' =>
    array(1) {
      'baz' =>
      string(3) "qoo"
    }
    'bar.baz' =>
    string(3) "qoo"
  }
}

For more details, please refer to the documentation.