function _gutenberg_get_mapped_fields in Gutenberg 8
Gets all mapped fields on the template (recursive).
Deprecated
in gutenberg:8.x-1.11
See also
https://www.drupal.org/node/3109876
2 calls to _gutenberg_get_mapped_fields()
- gutenberg_entity_presave in ./
gutenberg.module - Implements hook_entity_presave().
- gutenberg_form_node_form_alter in ./
gutenberg.module - Implements hook_form_node_form_alter().
File
- ./
gutenberg.module, line 760 - Provides integration with the Gutenberg editor.
Code
function _gutenberg_get_mapped_fields($template, &$result = []) {
if (empty($template)) {
return [];
}
foreach ($template as $key => $block) {
if (isset($block[1]) && isset($block[1]->mappingField)) {
$item = [];
$item['field'] = $block[1]->mappingField;
if (isset($block[1]->mappingAttribute)) {
$item['attribute'] = $block[1]->mappingAttribute;
}
$result[] = $item;
}
if (isset($block[2])) {
_gutenberg_get_mapped_fields($block[2], $result);
}
}
return $result;
}