protected function format_metadata($collection, $component, $internaldata) {
        foreach ($collection as $collectioninfo) {
            $privacyfields = $collectioninfo->get_privacy_fields();
            $fields = '';
            if (!empty($privacyfields)) {
                $fields = array_map(function($key, $field) use ($component) {
                    return [
                        'field_name' => $key,
                        'field_summary' => get_string($field, $component)
                    ];
                }, array_keys($privacyfields), $privacyfields);
            }
            // Can the metadata types be located somewhere else besides core?
            $items = explode('\\', get_class($collectioninfo));
            $type = array_pop($items);
            $typedata = [
                'name' => $collectioninfo->get_name(),
                'type' => $type,
                'fields' => $fields,
                'summary' => get_string($collectioninfo->get_summary(), $component)
            ];
            if (strpos($type, 'subsystem_link') === 0 || strpos($type, 'plugintype_link') === 0) {
                $typedata['link'] = true;
            }
            $internaldata['metadata'][] = $typedata;
        }
        return $internaldata;
    }