WP_CLI

Configurator::load_yml()private staticWP-CLI 1.0

Load values from a YAML file.

Method of the class: Configurator{}

No Hooks.

Return

Array. Declared configuration values

Usage

$result = Configurator::load_yml( $yml_file );
$yml_file(string) (required)
Path to the YAML file

Configurator::load_yml() code WP-CLI 2.8.0-alpha

private static function load_yml( $yml_file ) {
	if ( ! $yml_file ) {
		return [];
	}

	$config = Spyc::YAMLLoad( $yml_file );

	// Make sure config-file-relative paths are made absolute.
	$yml_file_dir = dirname( $yml_file );

	if ( isset( $config['path'] ) ) {
		self::absolutize( $config['path'], $yml_file_dir );
	}

	if ( isset( $config['require'] ) ) {
		self::arrayify( $config['require'] );
		$config['require'] = Utils\expand_globs( $config['require'] );
		foreach ( $config['require'] as &$path ) {
			self::absolutize( $path, $yml_file_dir );
		}
	}

	// Backwards compat
	// Command 'core config' was moved to 'config create'.
	if ( isset( $config['core config'] ) ) {
		$config['config create'] = $config['core config'];
		unset( $config['core config'] );
	}
	// Command 'checksum core' was moved to 'core verify-checksums'.
	if ( isset( $config['checksum core'] ) ) {
		$config['core verify-checksums'] = $config['checksum core'];
		unset( $config['checksum core'] );
	}
	// Command 'checksum plugin' was moved to 'plugin verify-checksums'.
	if ( isset( $config['checksum plugin'] ) ) {
		$config['plugin verify-checksums'] = $config['checksum plugin'];
		unset( $config['checksum plugin'] );
	}

	return $config;
}