class Configurator {
private $spec;
+
private $config = array();
+ private $extra_config = array();
function __construct( $path ) {
$this->spec = include $path;
}
function to_array() {
- return $this->config;
+ return array( $this->config, $this->extra_config );
}
/**
}
function merge_yml( $path ) {
- $this->merge_config( self::load_yml( $path ), 'file' );
+ foreach ( self::load_yml( $path ) as $key => $value ) {
+ if ( !isset( $this->spec[ $key ] ) || false === $this->spec[ $key ]['file'] ) {
+ $this->extra_config[ $key ] = $value;
+ } elseif ( $this->spec[ $key ]['multiple'] ) {
+ self::arrayify( $value );
+ $this->config[ $key ] = array_merge( $this->config[ $key ], $value );
+ } else {
+ $this->config[ $key ] = $value;
+ }
+ }
}
function merge_array( $config ) {
- $this->merge_config( $config, 'runtime' );
- }
-
- private function merge_config( $config, $type ) {
foreach ( $this->spec as $key => $details ) {
- if ( false !== $details[ $type ] && isset( $config[ $key ] ) ) {
+ if ( false !== $details['runtime'] && isset( $config[ $key ] ) ) {
$value = $config[ $key ];
if ( $details['multiple'] ) {
class Runner {
- private $global_config_path, $project_config_path, $config;
+ private $global_config_path, $project_config_path;
+
+ private $config, $extra_config;
private $arguments, $assoc_args;
$configurator->merge_array( $runtime_config );
}
- $this->config = $configurator->to_array();
+ list( $this->config, $this->extra_config ) = $configurator->to_array();
if ( !isset( $this->config['path'] ) ) {
$this->config['path'] = dirname( Utils\find_file_upward( 'wp-load.php' ) );