zendframework/zend-config-aggregator-parameters

此包已被废弃,不再维护。作者建议使用laminas/laminas-config-aggregator-parameters包。

为zendframework/zend-config-aggregator提供的后处理器扩展,允许在配置中使用模板参数

1.2.0 2019-11-22 17:24 UTC

This package is auto-updated.

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


README

仓库已废弃于2019-12-31

此仓库已迁移至 laminas/laminas-config-aggregator-parameters

Build Status Coverage Status

zendframework/zend-config-aggregator提供扩展,允许在配置中使用参数。

用法

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());

结果

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"
  }
}

有关更多详细信息,请参阅文档