WP_CLI

ContextManager::switch_context()publicWP-CLI 1.0

Switch the context in which to run WP-CLI.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

$ContextManager = new ContextManager();
$ContextManager->switch_context( $config );
$config(массив) (обязательный)
Associative array of configuration data.

Код ContextManager::switch_context() 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 );
}