WP_CLI\Bootstrap

RegisterFrameworkCommands{}WP-CLI 1.0

Class RegisterFrameworkCommands.

Register the commands that are directly included with the framework.

Хуков нет.

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

$RegisterFrameworkCommands = new RegisterFrameworkCommands();
// use class methods

Методы

  1. public process( BootstrapState $state )

Заметки

  • Пакет: WP_CLI\Bootstrap

Код RegisterFrameworkCommands{} WP-CLI 2.8.0-alpha

final class RegisterFrameworkCommands implements BootstrapStep {

	/**
	 * Process this single bootstrapping step.
	 *
	 * @param BootstrapState $state Contextual state to pass into the step.
	 *
	 * @return BootstrapState Modified state to pass to the next step.
	 */
	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;
	}
}