2 * Implements hook_entity_display_build_alter().
4 function {{ machine_name }}_entity_display_build_alter(&$build, $context) {
5 // Append RDF term mappings on displayed taxonomy links.
6 foreach (Element::children($build) as $field_name) {
7 $element = &$build[$field_name];
8 if ($element['#field_type'] == 'entity_reference' && $element['#formatter'] == 'entity_reference_label') {
9 foreach ($element['#items'] as $delta => $item) {
10 $term = $item->entity;
11 if (!empty($term->rdf_mapping['rdftype'])) {
12 $element[$delta]['#options']['attributes']['typeof'] = $term->rdf_mapping['rdftype'];
14 if (!empty($term->rdf_mapping['name']['predicates'])) {
15 $element[$delta]['#options']['attributes']['property'] = $term->rdf_mapping['name']['predicates'];