WP_CLI

Runner::do_early_invoke()privateWP-CLI 1.0

Perform the early invocation of a command.

Method of the class: Runner{}

No Hooks.

Return

null. Nothing.

Usage

// private - for code of main (parent) class only
$result = $this->do_early_invoke( $when );
$when(string) (required)
Named execution hook

Runner::do_early_invoke() code WP-CLI 2.8.0-alpha

private function do_early_invoke( $when ) {
	if ( ! isset( $this->early_invoke[ $when ] ) ) {
		return;
	}

	// Search the value of @when from the command method.
	$real_when = '';
	$r         = $this->find_command_to_run( $this->arguments );
	if ( is_array( $r ) ) {
		list( $command, $final_args, $cmd_path ) = $r;

		foreach ( $this->early_invoke as $_when => $_path ) {
			foreach ( $_path as $cmd ) {
				if ( $cmd === $cmd_path ) {
					$real_when = $_when;
				}
			}
		}
	}

	foreach ( $this->early_invoke[ $when ] as $path ) {
		if ( $this->cmd_starts_with( $path ) ) {
			if ( empty( $real_when ) || ( $real_when && $real_when === $when ) ) {
				$this->run_command_and_exit();
			}
		}
	}
}