admin/controllers/Settings.php
protected function extractFieldsets($sComponentSlug, $aSettings, $fieldSetIndex = 0)
    {
        foreach ($aSettings as $oSetting) {

            //  If the object contains a `fields` property then consider this a fieldset and inception
            if (isset($oSetting->fields)) {

                $fieldSetIndex++;

                if (!isset($this->data['fieldsets'][$fieldSetIndex])) {
                    $this->data['fieldsets'][$fieldSetIndex] = [
                        'legend' => $oSetting->legend,
                        'fields' => [],
                    ];
                }

                $this->extractFieldsets($sComponentSlug, $oSetting->fields, $fieldSetIndex);

            } else {

                $sValue = appSetting($oSetting->key, $sComponentSlug);
                if (!is_null($sValue)) {
                    $oSetting->default = $sValue;
                }

                if (!isset($this->data['fieldsets'][$fieldSetIndex])) {
                    $this->data['fieldsets'][$fieldSetIndex] = [
                        'legend' => '',
                        'fields' => [],
                    ];
                }

                $this->data['fieldsets'][$fieldSetIndex]['fields'][] = $oSetting;
                $this->aFields[]                                     = $oSetting;
            }
        }
    }
protected function extractFieldsets($sComponentSlug, $aSettings, $fieldSetIndex = 0)
    {
        foreach ($aSettings as $oSetting) {

            //  If the object contains a `fields` property then consider this a fieldset and inception
            if (isset($oSetting->fields)) {

                $fieldSetIndex++;

                if (!isset($this->data['fieldsets'][$fieldSetIndex])) {
                    $this->data['fieldsets'][$fieldSetIndex] = [
                        'legend' => $oSetting->legend,
                        'fields' => [],
                    ];
                }

                $this->extractFieldsets($sComponentSlug, $oSetting->fields, $fieldSetIndex);

            } else {

                $sValue = appSetting($oSetting->key, $sComponentSlug);
                if (!is_null($sValue)) {
                    $oSetting->default = $sValue;
                }

                if (!isset($this->data['fieldsets'][$fieldSetIndex])) {
                    $this->data['fieldsets'][$fieldSetIndex] = [
                        'legend' => '',
                        'fields' => [],
                    ];
                }

                $this->data['fieldsets'][$fieldSetIndex]['fields'][] = $oSetting;
                $this->aFields[]                                     = $oSetting;
            }
        }
    }
Recursively gets all the settings from the settings array

@param string $sComponentSlug The component's slug
@param array  $aSettings      The array of fieldsets and/or settings
@param int    $fieldSetIndex  The index of the fieldset