added initialize(), finalize() methods to upgrade scripts

This commit is contained in:
Taras Machyshyn
2015-02-17 13:02:02 +02:00
parent b6010a7ad7
commit b5b8ab4a8e
6 changed files with 28 additions and 2 deletions
@@ -504,6 +504,16 @@ abstract class Base
$this->getActionManager()->setAction($currentAction);
}
protected function initialize()
{
}
protected function finalize()
{
}
protected function beforeRunAction()
{
@@ -32,6 +32,8 @@ class Delete extends \Espo\Core\Upgrades\Actions\Base
throw new Error('Delete package package ID was not specified.');
}
$this->initialize();
$this->setProcessId($processId);
$this->beforeRunAction();
@@ -41,6 +43,8 @@ class Delete extends \Espo\Core\Upgrades\Actions\Base
$this->afterRunAction();
$this->finalize();
$GLOBALS['log']->debug('Delete package process ['.$processId.']: end run.');
}
@@ -50,6 +50,8 @@ class Install extends \Espo\Core\Upgrades\Actions\Base
$this->setProcessId($processId);
$this->initialize();
$this->isCopied = false;
/** check if an archive is unzipped, if no then unzip */
@@ -76,7 +78,7 @@ class Install extends \Espo\Core\Upgrades\Actions\Base
$this->isCopied = true;
/* remove files defined in a manifest */
$this->deleteFiles();
$this->deleteFiles(true);
if (!$this->systemRebuild()) {
$this->throwErrorAndRemovePackage('Error occurred while EspoCRM rebuild.');
@@ -92,6 +94,8 @@ class Install extends \Espo\Core\Upgrades\Actions\Base
/* delete unziped files */
$this->deletePackageFiles();
$this->finalize();
$GLOBALS['log']->debug('Installation process ['.$processId.']: end run.');
}
@@ -37,6 +37,8 @@ class Uninstall extends \Espo\Core\Upgrades\Actions\Base
$this->setProcessId($processId);
$this->initialize();
$this->checkIsWritable();
/* run before install script */
@@ -72,6 +74,8 @@ class Uninstall extends \Espo\Core\Upgrades\Actions\Base
/* delete backup files */
$this->deletePackageFiles();
$this->finalize();
$GLOBALS['log']->debug('Uninstallation process ['.$processId.']: end run.');
}
@@ -38,6 +38,8 @@ class Upload extends \Espo\Core\Upgrades\Actions\Base
$GLOBALS['log']->debug('Installation process ['.$processId.']: start upload the package.');
$this->initialize();
$packagePath = $this->getPackagePath();
$packageArchivePath = $this->getPackagePath(true);
@@ -55,6 +57,8 @@ class Upload extends \Espo\Core\Upgrades\Actions\Base
$this->isAcceptable();
$this->finalize();
$GLOBALS['log']->debug('Installation process ['.$processId.']: end upload the package.');
return $processId;
@@ -24,7 +24,7 @@ namespace Espo\Core\Upgrades\Actions\Upgrade;
class Install extends \Espo\Core\Upgrades\Actions\Base\Install
{
protected function afterRunAction()
protected function finalize()
{
$manifest = $this->getManifest();