From 7a7ece350ed93b9220bb9ef68ffefb7b82e02469 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Tue, 6 Jul 2010 18:31:55 +0000 Subject: [PATCH] Refactor installation into parent class, shouldn't be up to children to implement. Have the child pass callbacks to be done at beginning and end of stages for output --- includes/installer/Installer.php | 29 ++++++++++++++++++++++++ includes/installer/WebInstaller.php | 34 ++++++++--------------------- 2 files changed, 38 insertions(+), 25 deletions(-) diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index 2492b23cfd..798533a19b 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -853,6 +853,35 @@ abstract class Installer { return $this->installSteps; } + /** + * Actually perform the installation + * @param Array $startCB A callback array for the beginning of each step + * @param Array $endCB A callback array for the end of each step + * @return Array of Status objects + */ + public function performInstallation( $startCB, $endCB ) { + $installResults = array(); + foreach( $this->getInstallSteps() as $stepObj ) { + $step = is_array( $stepObj ) ? $stepObj['name'] : $stepObj; + call_user_func_array( $startCB, array( $step ) ); + $status = null; + + # Call our working function + if ( is_array( $step ) ) { + # A custom callaback + $callback = $stepObj['callback']; + $status = call_user_func_array( $callback, array() ); + } else { + # Boring implicitly named callback + $func = 'install' . ucfirst( $step ); + $status = $this->{$func}(); + } + call_user_func_array( $endCB, array( $step, $status ) ); + $installResults[$step] = $status; + } + return $installResults; + } + public function installExtensions() { global $wgHooks, $wgAutoloadClasses; $exts = $this->getVar( '_Extensions' ); diff --git a/includes/installer/WebInstaller.php b/includes/installer/WebInstaller.php index bbdbb7f250..09f3c18836 100644 --- a/includes/installer/WebInstaller.php +++ b/includes/installer/WebInstaller.php @@ -1577,42 +1577,26 @@ class WebInstaller_Install extends WebInstallerPage { } $this->startForm(); $this->addHTML(""); $this->endForm(); return true; } - private function startStage( $msg ) { - $this->addHTML( "
  • " . wfMsgHtml( $msg ) . wfMsg( 'ellipsis') ); + public function startStage( $step ) { + $this->addHTML( "
  • " . wfMsgHtml( "config-install-$step" ) . wfMsg( 'ellipsis') ); } - private function endStage( $success = true ) { + public function endStage( $step, $status ) { + $success = $status->isGood(); $msg = $success ? 'config-install-step-done' : 'config-install-step-failed'; $html = wfMsgHtml( 'word-separator' ) . wfMsgHtml( $msg ); if ( !$success ) { + $this->parent->showStatusBox( $status ); $html = "$html"; } $this->addHTML( $html . "
  • \n" ); -- 2.20.1