From ac041c617a386a39cd627f19fee70737ef564ec6 Mon Sep 17 00:00:00 2001 From: scribu Date: Sun, 30 Jun 2013 23:41:33 +0200 Subject: [PATCH] introduce get_configurator() getter We don't want to allow people to change the configurator instance just yet. --- php/WP_CLI/Dispatcher/RootCommand.php | 2 +- php/WP_CLI/Runner.php | 4 ++-- php/class-wp-cli.php | 6 +++++- php/commands/cli.php | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/php/WP_CLI/Dispatcher/RootCommand.php b/php/WP_CLI/Dispatcher/RootCommand.php index 67282fd6..311d295b 100644 --- a/php/WP_CLI/Dispatcher/RootCommand.php +++ b/php/WP_CLI/Dispatcher/RootCommand.php @@ -20,7 +20,7 @@ class RootCommand extends CompositeCommand { function get_extra_markdown() { $binding = array(); - foreach ( \WP_CLI::$configurator->get_spec() as $key => $details ) { + foreach ( \WP_CLI::get_configurator()->get_spec() as $key => $details ) { if ( false === $details['runtime'] ) continue; diff --git a/php/WP_CLI/Runner.php b/php/WP_CLI/Runner.php index b3de186f..dacbd302 100644 --- a/php/WP_CLI/Runner.php +++ b/php/WP_CLI/Runner.php @@ -269,7 +269,7 @@ class Runner { } public function before_wp_load() { - list( $args, $assoc_args, $runtime_config ) = \WP_CLI::$configurator->parse_args( + list( $args, $assoc_args, $runtime_config ) = \WP_CLI::get_configurator()->parse_args( array_slice( $GLOBALS['argv'], 1 ) ); list( $this->arguments, $this->assoc_args ) = self::back_compat_conversions( @@ -277,7 +277,7 @@ class Runner { $this->config_path = self::get_config_path( $runtime_config ); - $local_config = \WP_CLI::$configurator->load_config( $this->config_path ); + $local_config = \WP_CLI::get_configurator()->load_config( $this->config_path ); $this->config = $local_config; diff --git a/php/class-wp-cli.php b/php/class-wp-cli.php index 2df1376a..dc3462f2 100644 --- a/php/class-wp-cli.php +++ b/php/class-wp-cli.php @@ -8,7 +8,7 @@ use \WP_CLI\Dispatcher; */ class WP_CLI { - public static $configurator; + private static $configurator; public static $runner; private static $logger; @@ -36,6 +36,10 @@ class WP_CLI { self::$logger = $logger; } + static function get_configurator() { + return self::$configurator; + } + static function colorize( $string ) { return \cli\Colors::colorize( $string, self::$runner->in_color() ); } diff --git a/php/commands/cli.php b/php/commands/cli.php index 110fcb09..a31493b8 100644 --- a/php/commands/cli.php +++ b/php/commands/cli.php @@ -46,7 +46,7 @@ class CLI_Command extends WP_CLI_Command { * @subcommand param-dump */ function param_dump() { - echo json_encode( \WP_CLI::$configurator->get_spec() ); + echo json_encode( \WP_CLI::get_configurator()->get_spec() ); } /** -- 2.11.0