Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Register pre/post scripts for each step of the upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Nov 29, 2014
1 parent 4aca084 commit 65aa360
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions core/src/plugins/action.updater/class.AjaXplorerUpgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class AjaXplorerUpgrader
private $debugMode = FALSE;
private $cleanFile = "UPGRADE/CLEAN-FILES";
private $additionalScript = "UPGRADE/PHP-SCRIPT";
private $stepTriggerPrefix = "UPGRADE/PHP-";
private $releaseNote = "UPGRADE/NOTE";
private $htmlInstructions = "UPGRADE/NOTE-HTML";
private $dbUpgrade = "UPGRADE/DB-UPGRADE";
Expand Down Expand Up @@ -120,12 +121,15 @@ public function hasNextStep()
public function execute()
{
$stepKeys = array_keys($this->steps);
$stepName = $stepKeys[$this->step];
try {
$this->executeStepTrigger($stepName, "pre");
if (method_exists($this, $stepKeys[$this->step])) {
$this->result = call_user_func(array($this, $stepKeys[$this->step]));
} else {
$this->result = "Skipping step, method not found";
}
$this->executeStepTrigger($stepName, "post");
} catch (Exception $e) {
$this->error = $e->getMessage();
}
Expand Down Expand Up @@ -351,6 +355,16 @@ public function specificTask()

}

protected function executeStepTrigger($stepName, $trigger = "pre")
{
$scriptName = $this->workingFolder."/".$this->stepTriggerPrefix."-".$trigger."-".$stepName.".php";
if(!is_file($scriptName)) return "";
ob_start();
include($scriptName);
$output = ob_get_flush();
return "Executed specific task for ".$trigger."-".$stepName.": ".$output;
}

public function updateVersion()
{
// Finally copy VERSION file
Expand Down

0 comments on commit 65aa360

Please sign in to comment.