--- /dev/null
+/**
+ * Implements hook_entity_display_build_alter().
+ */
+function {{ machine_name }}_entity_display_build_alter(&$build, $context) {
+ // Append RDF term mappings on displayed taxonomy links.
+ foreach (Element::children($build) as $field_name) {
+ $element = &$build[$field_name];
+ if ($element['#field_type'] == 'entity_reference' && $element['#formatter'] == 'entity_reference_label') {
+ foreach ($element['#items'] as $delta => $item) {
+ $term = $item->entity;
+ if (!empty($term->rdf_mapping['rdftype'])) {
+ $element[$delta]['#options']['attributes']['typeof'] = $term->rdf_mapping['rdftype'];
+ }
+ if (!empty($term->rdf_mapping['name']['predicates'])) {
+ $element[$delta]['#options']['attributes']['property'] = $term->rdf_mapping['name']['predicates'];
+ }
+ }
+ }
+ }
+}