2 * Implements hook_entity_prepare_view().
4 function {{ machine_name }}_entity_prepare_view($entity_type_id, array $entities, array $displays, $view_mode) {
5 // Load a specific node into the user object for later theming.
6 if (!empty($entities) && $entity_type_id == 'user') {
7 // Only do the extra work if the component is configured to be
8 // displayed. This assumes a 'mymodule_addition' extra field has been
9 // defined for the entity bundle in hook_entity_extra_field_info().
11 foreach ($entities as $id => $entity) {
12 if ($displays[$entity->bundle()]->getComponent('mymodule_addition')) {
17 $nodes = mymodule_get_user_nodes($ids);
18 foreach ($ids as $id) {
19 $entities[$id]->user_node = $nodes[$id];