function tripal_chado_entity_view_alter

3.x tripal_chado.entity.inc tripal_chado_entity_view_alter(&$build)

Implements hook_entity_view_alter().

This function is used to support legacy Tripal v2 templates for use with Tripal v3 entities.

File

tripal_chado/includes/tripal_chado.entity.inc, line 304

Code

function tripal_chado_entity_view_alter(&$build) {
  // For the legacy support, we need to make sure the TOC
  // is built.
  if ($build['#entity_type'] == 'TripalEntity') {
    $enabled_templates = variable_get('tripal_chado_enabled_legacy_templates', array());
    $entity = $build['#entity'];
    $legacy_template = 'legacy_template--' . $entity->type;
    if (key_exists($legacy_template, $enabled_templates) && $enabled_templates[$legacy_template]) {
      $build['#entity']->nid = NULL;
      $build['#node'] = $build['#entity'];
      $modules = module_list();
      foreach ($modules as $mname => $details) {
        $function_name = $mname . '_node_view_alter';
        if (function_exists($function_name)) {
          $function_name($build);
        }
      }
    }
  }
}