WP_CLI\Bootstrap

RegisterFrameworkCommands::process()publicWP-CLI 1.0

Process this single bootstrapping step.

Method of the class: RegisterFrameworkCommands{}

No Hooks.

Return

BootstrapState. Modified state to pass to the next step.

Usage

$RegisterFrameworkCommands = new RegisterFrameworkCommands();
$RegisterFrameworkCommands->process( $state );
$state(BootstrapState) (required)
Contextual state to pass into the step.

RegisterFrameworkCommands::process() code WP-CLI 2.8.0-alpha

public function process( BootstrapState $state ) {
	$cmd_dir = WP_CLI_ROOT . '/php/commands';

	$iterator = new DirectoryIterator( $cmd_dir );

	foreach ( $iterator as $filename ) {
		if ( '.php' !== substr( $filename, - 4 ) ) {
			continue;
		}

		try {
			WP_CLI::debug(
				sprintf(
					'Adding framework command: %s',
					"$cmd_dir/$filename"
				),
				'bootstrap'
			);

			include_once "$cmd_dir/$filename";
		} catch ( Exception $exception ) {
			WP_CLI::warning(
				"Could not add command {$cmd_dir}/{$filename}. Reason: " . $exception->getMessage()
			);
		}
	}

	return $state;
}