mirror of
https://github.com/getgrav/grav.git
synced 2026-02-05 06:10:13 +01:00
Make saveConfig static so it's more easily accessible
This commit is contained in:
@@ -188,19 +188,18 @@ class Plugin implements EventSubscriberInterface
|
||||
* Persists to disk the plugin parameters currently stored in the Grav Config object
|
||||
*
|
||||
* @param string $plugin_name The name of the plugin whose config it should store.
|
||||
* If omitted, saves the current plugin
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
protected function saveConfig($plugin_name = '') {
|
||||
public static function saveConfig($plugin_name) {
|
||||
if (!$plugin_name) {
|
||||
$plugin_name = $this->name;
|
||||
return false;
|
||||
}
|
||||
|
||||
$locator = $this->grav['locator'];
|
||||
$locator = Grav::instance()['locator'];
|
||||
$filename = 'config://plugins/' . $plugin_name . '.yaml';
|
||||
$file = YamlFile::instance($locator->findResource($filename, true, true));
|
||||
$content = $this->grav['config']->get('plugins.' . $plugin_name);
|
||||
$content = Grav::instance()['config']->get('plugins.' . $plugin_name);
|
||||
$file->save($content);
|
||||
$file->free();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user