Added new Toggle and Task for switching gpm release

This commit is contained in:
Andy Miller
2016-04-15 16:18:02 -06:00
parent 6dc90180ef
commit 16d2f0a752
7 changed files with 178 additions and 7 deletions

View File

@@ -3,6 +3,7 @@ namespace Grav\Plugin;
use Grav\Common\Cache;
use Grav\Common\Config\Config;
use Grav\Common\File\CompiledYamlFile;
use Grav\Common\Filesystem\Folder;
use Grav\Common\GPM\Installer;
use Grav\Common\Grav;
@@ -275,6 +276,41 @@ class AdminController
return true;
}
/**
* Toggle the gpm.releases setting
*/
protected function taskGpmRelease()
{
if (!$this->authorizeTask('configuration', ['admin.configuration', 'admin.super'])) {
return false;
}
// Default release state
$release = 'stable';
// Get the testing release value if set
if ($this->grav['uri']->param('release') == 'testing') {
$release = 'testing';
}
$config = $this->grav['config'];
$current_release = $config->get('system.gpm.releases');
// If the releases setting is different, save it in the system config
if ($current_release != $release) {
$data = new Data\Data($config->get('system'));
$data->set('gpm.releases', $release);
// Get the file location
$file = CompiledYamlFile::instance($this->grav['locator']->findResource("config://system.yaml"));
$data->file($file);
// Save the configuration
$data->save();
$config->reload();
}
}
/**
* Keep alive
*/