Carbon_Fields\Helper\Helper::get_complex_fields PHP Метод

get_complex_fields() публичный статический Метод

Retrieve the complex field data for a certain field.
public static get_complex_fields ( string $type, string $name, integer $id = null ) : array
$type string Datastore type.
$name string Name of the field.
$id integer ID of the entry (optional).
Результат array Complex data entries.
    public static function get_complex_fields($type, $name, $id = null)
    {
        $datastore = Datastore::factory($type);
        if ($id !== null) {
            $datastore->set_id($id);
        }
        $group_rows = $datastore->load_values($name);
        $input_groups = array();
        foreach ($group_rows as $row) {
            if (!preg_match(self::get_complex_field_regex($name), $row['field_key'], $field_name)) {
                continue;
            }
            $row['field_value'] = maybe_unserialize($row['field_value']);
            // backward compatibility for Relationship field
            $row['field_value'] = self::parse_relationship_field($row['field_value']);
            $input_groups[$field_name['index']]['_type'] = $field_name['group'];
            if (!empty($field_name['trailing'])) {
                $input_groups = self::expand_nested_field($input_groups, $row, $field_name);
            } else {
                if (!empty($field_name['sub'])) {
                    $input_groups[$field_name['index']][$field_name['key']][$field_name['sub']] = $row['field_value'];
                } else {
                    $input_groups[$field_name['index']][$field_name['key']] = $row['field_value'];
                }
            }
        }
        // create groups list with loaded fields
        self::ksort_recursive($input_groups);
        return $input_groups;
    }