mirror of
https://github.com/getgrav/grav.git
synced 2026-03-05 12:01:37 +01:00
Handle saving a new group
This commit is contained in:
@@ -30,6 +30,16 @@ class Group extends Data
|
||||
return $groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a group exists
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public static function group_exists($groupname)
|
||||
{
|
||||
return isset(self::groups()[$groupname]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a group by name
|
||||
*
|
||||
@@ -37,7 +47,11 @@ class Group extends Data
|
||||
*/
|
||||
public static function load($groupname)
|
||||
{
|
||||
$content = self::groups()[$groupname];
|
||||
if (self::group_exists($groupname)) {
|
||||
$content = self::groups()[$groupname];
|
||||
} else {
|
||||
$content = [];
|
||||
}
|
||||
|
||||
$blueprints = new Blueprints('blueprints://');
|
||||
$blueprint = $blueprints->get('user/group');
|
||||
@@ -83,7 +97,9 @@ class Group extends Data
|
||||
foreach($fields as $field) {
|
||||
if ($field['type'] == 'text') {
|
||||
$value = $field['name'];
|
||||
self::getGrav()['config']->set("site.groups.$this->groupname.$value", $this->items[$field['name']]);
|
||||
if (isset($this->items[$value])) {
|
||||
self::getGrav()['config']->set("site.groups.$this->groupname.$value", $this->items[$value]);
|
||||
}
|
||||
}
|
||||
if ($field['type'] == 'array') {
|
||||
$value = $field['name'];
|
||||
|
||||
Reference in New Issue
Block a user