protected function processNestedGroups($group)
    {
        $data = [];

        if (isset($group['fields']) && is_array($group['fields'])) {
            foreach ($group['fields'] as $fieldName => $field) {
                if (!empty($field['value'])) {
                    $data['fields'][$fieldName] = ['value' => $field['value']];
                }
            }
        }

        if (isset($group['groups']) && is_array($group['groups'])) {
            foreach ($group['groups'] as $groupName => $groupData) {
                $nestedGroup = $this->processNestedGroups($groupData);
                if (!empty($nestedGroup)) {
                    $data['groups'][$groupName] = $nestedGroup;
                }
            }
        }

        return $data;
    }
protected function processNestedGroups($group)
    {
        $data = [];

        if (isset($group['fields']) && is_array($group['fields'])) {
            foreach ($group['fields'] as $fieldName => $field) {
                if (!empty($field['value'])) {
                    $data['fields'][$fieldName] = ['value' => $field['value']];
                }
            }
        }

        if (isset($group['groups']) && is_array($group['groups'])) {
            foreach ($group['groups'] as $groupName => $groupData) {
                $nestedGroup = $this->processNestedGroups($groupData);
                if (!empty($nestedGroup)) {
                    $data['groups'][$groupName] = $nestedGroup;
                }
            }
        }

        return $data;
    }
protected function processNestedGroups ( $ group ) { $ data = [ ] ; if ( isset ( $ group [ 'fields' ] ) && is_array ( $ group [ 'fields' ] ) ) { foreach ( $ group [ 'fields' ] as $ fieldName => $ field ) { if ( ! empty ( $ field [ 'value' ] ) ) { $ data [ 'fields' ] [ $ fieldName ] = [ 'value' => $ field [ 'value' ] ] ; } } } if ( isset ( $ group [ 'groups' ] ) && is_array ( $ group [ 'groups' ] ) ) { foreach ( $ group [ 'groups' ] as $ groupName => $ groupData ) { $ nestedGroup = $ this -> processNestedGroups ( $ groupData ) ; if ( ! empty ( $ nestedGroup ) ) { $ data [ 'groups' ] [ $ groupName ] = $ nestedGroup ; } } } return $ data ; }
Process nested groups

@param mixed $group The configuration groups

@return array
Process nested groups