classes/Collections/Elements.php
public function assocConfig($include_extra = false)
    {
        // Load the config data if it isn't already
        if (!$this->config) {
            $this->loadConfig();
        }

        // Loop through the YAML config and make flattened keys.  The ternary
        // operators in here allow a shorthand version of the YAML config as
        // described in the docs.
        $config = [];
        foreach ($this->config as $page => $page_data) {
            foreach (isset($page_data['sections']) ? $page_data['sections'] : $page_data as $section => $section_data) {
                foreach (isset($section_data['fields']) ? $section_data['fields'] : $section_data as $field => $field_data) {

                    // Determine the type of field
                    $field_parts = explode(',', $field);
                    $field = $field_parts[0];
                    if (count($field_parts) == 2) {
                        $type = $field_parts[1];
                    } // If concatted onto the field name
                    elseif (is_array($field_data) && isset($field_data['type'])) {
                        $type = $field_data['type'];
                    } // Explicitly set
                    else {
                        $type = 'text';
                    } // Default type

                    // Determine the value
                    if (is_array($field_data) && array_key_exists('value', $field_data)) {
                        $value = $field_data['value'];
                    } elseif (is_scalar($field_data)) {
                        $value = $field_data;
                    } // String, boolean, int, etc
                    else {
                        $value = null;
                    }

                    // Build the value array
                    $el = ['type' => $type, 'value' => $value];
                    if ($this->has_extra || $include_extra) {
                        $this->mergeExtra($el, $field, $field_data);
                        $this->mergeExtra($el, $section, $section_data, 'section_');
                        $this->mergeExtra($el, $page, $page_data, 'page_');
                        $el['rules'] = isset($field_data['rules']) ? $field_data['rules'] : null;
                    }

                    // Add the config
                    $config["{$page}.{$section}.{$field}"] = $el;
                }
            }
        }

        // Return the flattened config
        return $config;
    }
public function assocConfig($include_extra = false)
    {
        // Load the config data if it isn't already
        if (!$this->config) {
            $this->loadConfig();
        }

        // Loop through the YAML config and make flattened keys.  The ternary
        // operators in here allow a shorthand version of the YAML config as
        // described in the docs.
        $config = [];
        foreach ($this->config as $page => $page_data) {
            foreach (isset($page_data['sections']) ? $page_data['sections'] : $page_data as $section => $section_data) {
                foreach (isset($section_data['fields']) ? $section_data['fields'] : $section_data as $field => $field_data) {

                    // Determine the type of field
                    $field_parts = explode(',', $field);
                    $field = $field_parts[0];
                    if (count($field_parts) == 2) {
                        $type = $field_parts[1];
                    } // If concatted onto the field name
                    elseif (is_array($field_data) && isset($field_data['type'])) {
                        $type = $field_data['type'];
                    } // Explicitly set
                    else {
                        $type = 'text';
                    } // Default type

                    // Determine the value
                    if (is_array($field_data) && array_key_exists('value', $field_data)) {
                        $value = $field_data['value'];
                    } elseif (is_scalar($field_data)) {
                        $value = $field_data;
                    } // String, boolean, int, etc
                    else {
                        $value = null;
                    }

                    // Build the value array
                    $el = ['type' => $type, 'value' => $value];
                    if ($this->has_extra || $include_extra) {
                        $this->mergeExtra($el, $field, $field_data);
                        $this->mergeExtra($el, $section, $section_data, 'section_');
                        $this->mergeExtra($el, $page, $page_data, 'page_');
                        $el['rules'] = isset($field_data['rules']) ? $field_data['rules'] : null;
                    }

                    // Add the config
                    $config["{$page}.{$section}.{$field}"] = $el;
                }
            }
        }

        // Return the flattened config
        return $config;
    }
public function assocConfig ( $ include_extra = false ) { // Load the config data if it isn't already if ( ! $ this -> config ) { $ this -> loadConfig ( ) ; } // Loop through the YAML config and make flattened keys.  The ternary // operators in here allow a shorthand version of the YAML config as // described in the docs. $ config = [ ] ; foreach ( $ this -> config as $ page => $ page_data ) { foreach ( isset ( $ page_data [ 'sections' ] ) ? $ page_data [ 'sections' ] : $ page_data as $ section => $ section_data ) { foreach ( isset ( $ section_data [ 'fields' ] ) ? $ section_data [ 'fields' ] : $ section_data as $ field => $ field_data ) { // Determine the type of field $ field_parts = explode ( ',' , $ field ) ; $ field = $ field_parts [ 0 ] ; if ( count ( $ field_parts ) == 2 ) { $ type = $ field_parts [ 1 ] ; } // If concatted onto the field name elseif ( is_array ( $ field_data ) && isset ( $ field_data [ 'type' ] ) ) { $ type = $ field_data [ 'type' ] ; } // Explicitly set else { $ type = 'text' ; } // Default type // Determine the value if ( is_array ( $ field_data ) && array_key_exists ( 'value' , $ field_data ) ) { $ value = $ field_data [ 'value' ] ; } elseif ( is_scalar ( $ field_data ) ) { $ value = $ field_data ; } // String, boolean, int, etc else { $ value = null ; } // Build the value array $ el = [ 'type' => $ type , 'value' => $ value ] ; if ( $ this -> has_extra || $ include_extra ) { $ this -> mergeExtra ( $ el , $ field , $ field_data ) ; $ this -> mergeExtra ( $ el , $ section , $ section_data , 'section_' ) ; $ this -> mergeExtra ( $ el , $ page , $ page_data , 'page_' ) ; $ el [ 'rules' ] = isset ( $ field_data [ 'rules' ] ) ? $ field_data [ 'rules' ] : null ; } // Add the config $ config [ "{$page}.{$section}.{$field}" ] = $ el ; } } } // Return the flattened config return $ config ; }
Massage the YAML config file into a single, flat associative array

@param  boolean $include_extra Include attibutes that are only needed by Admin UIs
@return array
Massage the YAML config file into a single flat associative array