WP_CLI

Runner::init_config()publicWP-CLI 1.0

Метод класса: Runner{}

Хуков нет.

Возвращает

null. Ничего.

Использование

$Runner = new Runner();
$Runner->init_config();

Код Runner::init_config() WP-CLI 2.8.0-alpha

public function init_config() {
	$configurator = WP_CLI::get_configurator();

	$argv = array_slice( $GLOBALS['argv'], 1 );

	$this->alias = null;
	if ( ! empty( $argv[0] ) && preg_match( '#' . Configurator::ALIAS_REGEX . '#', $argv[0], $matches ) ) {
		$this->alias = array_shift( $argv );
	}

	// File config
	{
		$this->global_config_path  = $this->get_global_config_path();
		$this->project_config_path = $this->get_project_config_path();

		$configurator->merge_yml( $this->global_config_path, $this->alias );
		$config                         = $configurator->to_array();
		$this->required_files['global'] = $config[0]['require'];
		$configurator->merge_yml( $this->project_config_path, $this->alias );
		$config                          = $configurator->to_array();
		$this->required_files['project'] = $config[0]['require'];
	}

	// Runtime config and args
	{
		list( $args, $assoc_args, $this->runtime_config ) = $configurator->parse_args( $argv );

		list( $this->arguments, $this->assoc_args ) = self::back_compat_conversions(
			$args,
			$assoc_args
		);

		$configurator->merge_array( $this->runtime_config );
	}

	list( $this->config, $this->extra_config ) = $configurator->to_array();
	$this->aliases                             = $configurator->get_aliases();
	if ( count( $this->aliases ) && ! isset( $this->aliases['@all'] ) ) {
		$this->aliases         = array_reverse( $this->aliases );
		$this->aliases['@all'] = 'Run command against every registered alias.';
		$this->aliases         = array_reverse( $this->aliases );
	}
	$this->required_files['runtime'] = $this->config['require'];
}