WP_CLI\Bootstrap

InitializeContexts::process()publicWP-CLI 1.0

Process this single bootstrapping step.

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

Хуков нет.

Возвращает

BootstrapState. Modified state to pass to the next step.

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

$InitializeContexts = new InitializeContexts();
$InitializeContexts->process( $state );
$state(BootstrapState) (обязательный)
Contextual state to pass into the step.

Код InitializeContexts::process() WP-CLI 2.8.0-alpha

public function process( BootstrapState $state ) {
	$context_manager = new ContextManager();

	$contexts = [
		Context::CLI      => new Context\Cli(),
		Context::ADMIN    => new Context\Admin(),
		Context::FRONTEND => new Context\Frontend(),
		Context::AUTO     => new Context\Auto( $context_manager ),
	];

	$contexts = WP_CLI::do_hook( 'before_registering_contexts', $contexts );

	foreach ( $contexts as $name => $implementation ) {
		$context_manager->register_context( $name, $implementation );
	}

	$state->setValue( 'context_manager', $context_manager );

	return $state;
}