hook_entity_display_build_alter(&$build, $context)
Alter the render array generated by an EntityDisplay for an entity.
array $build: The renderable array generated by the EntityDisplay.
array $context: An associative array containing:
function hook_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']; } } } } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!entity.api.php/function/hook_entity_display_build_alter/8.1.x