OSDN Git Service

keep 'not found' message in Fetcher child classes
authorscribu <mail@scribu.net>
Sat, 9 Nov 2013 23:01:38 +0000 (01:01 +0200)
committerscribu <mail@scribu.net>
Sat, 9 Nov 2013 23:01:41 +0000 (01:01 +0200)
otherwise, might get a mismatch between the class and the message

php/WP_CLI/Fetcher.php
php/WP_CLI/FetcherComment.php
php/WP_CLI/FetcherPlugin.php
php/WP_CLI/FetcherTheme.php
php/WP_CLI/FetcherUser.php
php/commands/comment.php
php/commands/plugin.php
php/commands/theme.php
php/commands/user.php

index bf24465..0ef9f92 100644 (file)
@@ -4,14 +4,10 @@ namespace WP_CLI;
 
 abstract class Fetcher {
 
-       protected $msg;
-
        /**
         * @param string $msg The message to display when an item is not found
         */
-       function __construct( $msg ) {
-               $this->msg = $msg;
-       }
+       protected $msg;
 
        /**
         * @param string $arg The raw CLI argument
index 806ece1..167b043 100644 (file)
@@ -4,6 +4,8 @@ namespace WP_CLI;
 
 class FetcherComment extends Fetcher {
 
+       protected $msg = "Comment with ID %s does not exist.";
+
        public function get( $arg ) {
                $comment_id = (int) $arg;
                $comment = get_comment( $comment_id );
index 3c8893a..bd68712 100644 (file)
@@ -4,6 +4,8 @@ namespace WP_CLI;
 
 class FetcherPlugin extends Fetcher {
 
+       protected $msg = "The '%s' plugin could not be found.";
+
        public function get( $name ) {
                $plugins = get_plugins( '/' . $name );
 
index 0327763..5066983 100644 (file)
@@ -4,6 +4,8 @@ namespace WP_CLI;
 
 class FetcherTheme extends Fetcher {
 
+       protected $msg = "The '%s' theme could not be found.";
+
        public function get( $name ) {
                $theme = wp_get_theme( $name );
 
index aea6ffb..e1111e0 100644 (file)
@@ -4,6 +4,8 @@ namespace WP_CLI;
 
 class FetcherUser extends Fetcher {
 
+       protected $msg = "Invalid user ID or login: '%s'";
+
        public function get( $id_or_login ) {
                if ( is_numeric( $id_or_login ) )
                        $user = get_user_by( 'id', $id_or_login );
index cb7c4f0..aa73d16 100644 (file)
@@ -19,7 +19,7 @@ class Comment_Command extends \WP_CLI\CommandWithDBObject {
        );
 
        public function __construct() {
-               $this->fetcher = new \WP_CLI\FetcherComment( "Comment with ID %s does not exist." );
+               $this->fetcher = new \WP_CLI\FetcherComment;
        }
 
        /**
index ab0bd6b..ff90c5c 100644 (file)
@@ -24,7 +24,7 @@ class Plugin_Command extends \WP_CLI\CommandWithUpgrade {
 
                parent::__construct();
 
-               $this->fetcher = new \WP_CLI\FetcherPlugin( "The '%s' plugin could not be found." );
+               $this->fetcher = new \WP_CLI\FetcherPlugin;
        }
 
        protected function get_upgrader_class( $force ) {
index 8a8d6dd..d543778 100644 (file)
@@ -21,7 +21,7 @@ class Theme_Command extends \WP_CLI\CommandWithUpgrade {
        function __construct() {
                parent::__construct();
 
-               $this->fetcher = new \WP_CLI\FetcherTheme( "The '%s' theme could not be found." );
+               $this->fetcher = new \WP_CLI\FetcherTheme;
        }
 
        protected function get_upgrader_class( $force ) {
index df0c65e..cf18fcb 100644 (file)
@@ -18,7 +18,7 @@ class User_Command extends \WP_CLI\CommandWithDBObject {
        );
 
        public function __construct() {
-               $this->fetcher = new \WP_CLI\FetcherUser( "Invalid user ID or login: '%s'" );
+               $this->fetcher = new \WP_CLI\FetcherUser;
        }
 
        /**