From: withoutaname Date: Fri, 4 Jul 2014 07:34:17 +0000 (-0700) Subject: Generalize Installer::showStatusMessage() X-Git-Tag: 1.31.0-rc.0~14967 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/password.php?a=commitdiff_plain;h=1c1e321af7977722073116fb6846f494502f6805;p=lhc%2Fweb%2Fwiklou.git Generalize Installer::showStatusMessage() Folds functionality from child classes back into a concrete implementation in the parent class, reducing code duplication. Change-Id: I697fe697dbd59d5db6fc77aba20af322e6011782 --- diff --git a/includes/installer/CliInstaller.php b/includes/installer/CliInstaller.php index 1c7762b836..c6939a81d4 100644 --- a/includes/installer/CliInstaller.php +++ b/includes/installer/CliInstaller.php @@ -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 ); diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index 015ac53d17..7c67ee8dac 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -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. diff --git a/includes/installer/WebInstaller.php b/includes/installer/WebInstaller.php index f62470eec4..ea86231e0d 100644 --- a/includes/installer/WebInstaller.php +++ b/includes/installer/WebInstaller.php @@ -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.