Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d7 / hook / field_attach_view_alter.twig
1 /**
2  * Implements hook_field_attach_view_alter().
3  */
4 function {{ machine_name }}_field_attach_view_alter(&$output, $context) {
5   // Append RDF term mappings on displayed taxonomy links.
6   foreach (element_children($output) as $field_name) {
7     $element = &$output[$field_name];
8     if ($element['#field_type'] == 'taxonomy_term_reference' && $element['#formatter'] == 'taxonomy_term_reference_link') {
9       foreach ($element['#items'] as $delta => $item) {
10         $term = $item['taxonomy_term'];
11         if (!empty($term->rdf_mapping['rdftype'])) {
12           $element[$delta]['#options']['attributes']['typeof'] = $term->rdf_mapping['rdftype'];
13         }
14         if (!empty($term->rdf_mapping['name']['predicates'])) {
15           $element[$delta]['#options']['attributes']['property'] = $term->rdf_mapping['name']['predicates'];
16         }
17       }
18     }
19   }
20 }