public function save()
    {
        $grav = Grav::instance();

        /** @var Config $config */
        $config = $grav['config'];

        $blueprints = new Blueprints();
        $blueprint = $blueprints->get('user/group');

        $config->set("groups.{$this->get('groupname')}", []);

        $fields = $blueprint->fields();
        foreach ($fields as $field) {
            if ($field['type'] === 'text') {
                $value = $field['name'];
                if (isset($this->items['data'][$value])) {
                    $config->set("groups.{$this->get('groupname')}.{$value}", $this->items['data'][$value]);
                }
            }
            if ($field['type'] === 'array' || $field['type'] === 'permissions') {
                $value = $field['name'];
                $arrayValues = Utils::getDotNotation($this->items['data'], $field['name']);

                if ($arrayValues) {
                    foreach ($arrayValues as $arrayIndex => $arrayValue) {
                        $config->set("groups.{$this->get('groupname')}.{$value}.{$arrayIndex}", $arrayValue);
                    }
                }
            }
        }

        $type = 'groups';
        $blueprints = $this->blueprints();

        $filename = CompiledYamlFile::instance($grav['locator']->findResource("config://{$type}.yaml"));

        $obj = new Data($config->get($type), $blueprints);
        $obj->file($filename);
        $obj->save();
    }
public function save()
    {
        $grav = Grav::instance();

        /** @var Config $config */
        $config = $grav['config'];

        $blueprints = new Blueprints();
        $blueprint = $blueprints->get('user/group');

        $config->set("groups.{$this->get('groupname')}", []);

        $fields = $blueprint->fields();
        foreach ($fields as $field) {
            if ($field['type'] === 'text') {
                $value = $field['name'];
                if (isset($this->items['data'][$value])) {
                    $config->set("groups.{$this->get('groupname')}.{$value}", $this->items['data'][$value]);
                }
            }
            if ($field['type'] === 'array' || $field['type'] === 'permissions') {
                $value = $field['name'];
                $arrayValues = Utils::getDotNotation($this->items['data'], $field['name']);

                if ($arrayValues) {
                    foreach ($arrayValues as $arrayIndex => $arrayValue) {
                        $config->set("groups.{$this->get('groupname')}.{$value}.{$arrayIndex}", $arrayValue);
                    }
                }
            }
        }

        $type = 'groups';
        $blueprints = $this->blueprints();

        $filename = CompiledYamlFile::instance($grav['locator']->findResource("config://{$type}.yaml"));

        $obj = new Data($config->get($type), $blueprints);
        $obj->file($filename);
        $obj->save();
    }
public function save ( ) { $ grav = Grav :: instance ( ) ; /** @var Config $config */ $ config = $ grav [ 'config' ] ; $ blueprints = new Blueprints ( ) ; $ blueprint = $ blueprints -> get ( 'user/group' ) ; $ config -> set ( "groups.{$this->get('groupname')}" , [ ] ) ; $ fields = $ blueprint -> fields ( ) ; foreach ( $ fields as $ field ) { if ( $ field [ 'type' ] === 'text' ) { $ value = $ field [ 'name' ] ; if ( isset ( $ this -> items [ 'data' ] [ $ value ] ) ) { $ config -> set ( "groups.{$this->get('groupname')}.{$value}" , $ this -> items [ 'data' ] [ $ value ] ) ; } } if ( $ field [ 'type' ] === 'array' || $ field [ 'type' ] === 'permissions' ) { $ value = $ field [ 'name' ] ; $ arrayValues = Utils :: getDotNotation ( $ this -> items [ 'data' ] , $ field [ 'name' ] ) ; if ( $ arrayValues ) { foreach ( $ arrayValues as $ arrayIndex => $ arrayValue ) { $ config -> set ( "groups.{$this->get('groupname')}.{$value}.{$arrayIndex}" , $ arrayValue ) ; } } } } $ type = 'groups' ; $ blueprints = $ this -> blueprints ( ) ; $ filename = CompiledYamlFile :: instance ( $ grav [ 'locator' ] -> findResource ( "config://{$type}.yaml" ) ) ; $ obj = new Data ( $ config -> get ( $ type ) , $ blueprints ) ; $ obj -> file ( $ filename ) ; $ obj -> save ( ) ; }
Save a group
Save a group