Skip to content

Commit

Permalink
Dev: Some cleaning in reading config file
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Aug 23, 2016
1 parent 0e81f36 commit 9411411
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions application/libraries/PluginManager/PluginBase.php
Expand Up @@ -396,17 +396,12 @@ public function readConfigFile()
// Failed. Popup error message.
$this->showConfigErrorNotification();
}
else
else if ($this->configIsNewVersion())
{
if ($this->configIsNewVersion())
{
// Do everything related to reading config fields
$this->checkActive();
}
else
{
// Nothing to do, config has not changed
}
// Do everything related to reading config fields
// TODO: Create a config object for this? One object for each config field? Then loop through those fields.
$this->checkActive();
$this->saveNewVersion();
}
}
else
Expand Down Expand Up @@ -440,7 +435,6 @@ protected function checkActive()

if ($result->get('success') !== false)
{
$pluginModel->version = $this->config->version;
$pluginModel->active = 1;
$pluginModel->update();
}
Expand Down Expand Up @@ -496,4 +490,16 @@ protected function configIsNewVersion()
return empty($pluginModel->version) ||
version_compare($pluginModel->version, $this->config->version) === -1;
}

/**
* Saves the new version from config into database
* @return void
*/
protected function saveNewVersion()
{
$pluginModel = \Plugin::model()->findByPk($this->id);
$pluginModel->version = $this->config->version;
$pluginModel->update();
}

}

0 comments on commit 9411411

Please sign in to comment.