function rdf_entity_prepare_view

rdf_entity_prepare_view($entity_type, array $entities, array $displays)

Implements hook_entity_prepare_view().

File

core/modules/rdf/rdf.module, line 208
Enables semantically enriched output for Drupal sites in the form of RDFa.

Code

function rdf_entity_prepare_view($entity_type, array $entities, array $displays) {
  // Iterate over the RDF mappings for each entity and prepare the RDFa
  // attributes to be added inside field formatters.
  foreach ($entities as $entity) {
    $mapping = rdf_get_mapping($entity_type, $entity->bundle());
    // Only prepare the RDFa attributes for the fields which are configured to
    // be displayed.
    foreach ($displays[$entity->bundle()]->getComponents() as $name => $options) {
      $field_mapping = $mapping->getPreparedFieldMapping($name);
      if ($field_mapping) {
        foreach ($entity->get($name) as $item) {
          $item->_attributes += rdf_rdfa_attributes($field_mapping, $item->toArray());
        }
      }
    }
  }
}

© 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!modules!rdf!rdf.module/function/rdf_entity_prepare_view/8.1.x