mirror of
https://github.com/getgrav/grav.git
synced 2025-12-05 15:29:57 +01:00
Allow to remove a group
This commit is contained in:
@@ -95,9 +95,33 @@ class Group extends Data
|
||||
|
||||
$type = 'site';
|
||||
$blueprints = $this->blueprints("config/{$type}");
|
||||
$obj = new Data(self::getGrav()['config']->get('site'), $blueprints);
|
||||
$obj = new Data(self::getGrav()['config']->get($type), $blueprints);
|
||||
$file = CompiledYamlFile::instance(self::getGrav()['locator']->findResource("config://{$type}.yaml"));
|
||||
$obj->file($file);
|
||||
$obj->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a group
|
||||
*
|
||||
* @param string $username
|
||||
* @return bool True is the action was performed
|
||||
*/
|
||||
public static function remove($groupname)
|
||||
{
|
||||
$blueprints = new Blueprints('blueprints://');
|
||||
$blueprint = $blueprints->get('user/group');
|
||||
|
||||
$groups = self::getGrav()['config']->get("site.groups");
|
||||
unset($groups[$groupname]);
|
||||
self::getGrav()['config']->set("site.groups", $groups);
|
||||
|
||||
$type = 'site';
|
||||
$obj = new Data(self::getGrav()['config']->get($type), $blueprint);
|
||||
$file = CompiledYamlFile::instance(self::getGrav()['locator']->findResource("config://{$type}.yaml"));
|
||||
$obj->file($file);
|
||||
$obj->save();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user