zendframework/zend-config-aggregator-parameters

This package is abandoned and no longer maintained. The author suggests using the laminas/laminas-config-aggregator-parameters package instead.

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

1.2.0 2019-11-22 17:24 UTC

This package is auto-updated.

Last update: 2020-01-29 14:51:33 UTC


README

Repository abandoned 2019-12-31

This repository has moved to laminas/laminas-config-aggregator-parameters.

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%',
            'parameterized_parameter_usage' => '%bar.quux%',
        ]),
    ],
    null,
    [
        new ParameterPostProcessor([
            'foo' => 'bar',
            'bar' => [
                'baz' => 'qoo',
                'quux' => '%foo%', 
            ],
        ]),
    ]
);

var_dump($aggregator->getMergedConfig());

Result:

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

For more details, please refer to the documentation.