Generalize Installer::showStatusMessage()
authorwithoutaname <drevitchi@gmail.com>
Fri, 4 Jul 2014 07:34:17 +0000 (00:34 -0700)
committerLegoktm <legoktm.wikipedia@gmail.com>
Sun, 13 Jul 2014 01:52:49 +0000 (01:52 +0000)
Folds functionality from child classes back into a
concrete implementation in the parent class, reducing code duplication.

Change-Id: I697fe697dbd59d5db6fc77aba20af322e6011782

includes/installer/CliInstaller.php
includes/installer/Installer.php
includes/installer/WebInstaller.php

index 1c7762b..c6939a8 100644 (file)
@@ -179,16 +179,11 @@ class CliInstaller extends Installer {
        public function showHelpBox( $msg /*, ... */ ) {
        }
 
+       /**
+        * @param Status $status
+        */
        public function showStatusMessage( Status $status ) {
-               $warnings = array_merge( $status->getWarningsArray(),
-                       $status->getErrorsArray() );
-
-               if ( count( $warnings ) !== 0 ) {
-                       foreach ( $warnings as $w ) {
-                               call_user_func_array( array( $this, 'showMessage' ), $w );
-                       }
-               }
-
+               parent::showStatusMessage( $status );
                if ( !$status->isOk() ) {
                        echo "\n";
                        exit( 1 );
index 015ac53..7c67ee8 100644 (file)
@@ -351,10 +351,17 @@ abstract class Installer {
        abstract public function showError( $msg /*, ... */ );
 
        /**
-        * Show a message to the installing user by using a Status object
+        * Shows messages to the user through a Status object
         * @param Status $status
         */
-       abstract public function showStatusMessage( Status $status );
+       public function showStatusMessage( Status $status ) {
+               $errors = array_merge( $status->getErrorsArray(), $status->getWarningsArray() );
+               if ( $errors ) {
+                       foreach ( $errors as $error ) {
+                               call_user_func( 'showMessage', $error );
+                       }
+               }
+       }
 
        /**
         * Constructor, always call this from child classes.
index f62470e..ea86231 100644 (file)
@@ -729,16 +729,6 @@ class WebInstaller extends Installer {
                $this->output->addHTML( $html );
        }
 
-       /**
-        * @param Status $status
-        */
-       public function showStatusMessage( Status $status ) {
-               $errors = array_merge( $status->getErrorsArray(), $status->getWarningsArray() );
-               foreach ( $errors as $error ) {
-                       call_user_func_array( array( $this, 'showMessage' ), $error );
-               }
-       }
-
        /**
         * Label a control by wrapping a config-input div around it and putting a
         * label before it.