WP_CLI

ContextManager::switch_context()publicWP-CLI 1.0

Switch the context in which to run WP-CLI.

Method of the class: ContextManager{}

No Hooks.

Return

null. Nothing.

Usage

$ContextManager = new ContextManager();
$ContextManager->switch_context( $config );
$config(array) (required)
Associative array of configuration data.

ContextManager::switch_context() code WP-CLI 2.8.0-alpha

public function switch_context( $config ) {
	$context = isset( $config['context'] )
		? $config['context']
		: $this->current_context;

	if ( ! array_key_exists( $context, $this->contexts ) ) {
		WP_CLI::error( "Unknown context '{$context}'" );
	}

	WP_CLI::debug( "Using context '{$context}'", Context::DEBUG_GROUP );

	$this->current_context = $context;
	$this->contexts[ $context ]->process( $config );
}