You are here

function date_views_base_tables in Date 8

Same name and namespace in other branches
  1. 7.3 date_views/date_views.module \date_views_base_tables()
  2. 7.2 date_views/date_views.module \date_views_base_tables()

Helper function to map entity types to the Views base table they use, to make it easier to infer the entity type from a base table.

Views has a new handler called views_handler_field_entity() that loads entities, and you can use something like the following to get the entity type from a view, but not all our base tables contain the entity information we need, (i.e. revisions) so it won't work here and we resort to creating information from entity_get_info().

// A method to get the entity type for a base table. $table_data = views_fetch_data($base_table); if (!isset($table_data['table']['base']['entity type'])) { return FALSE; } $entity_type = $table_data['table']['base']['entity type'];

1 call to date_views_base_tables()
date_views_views_data in date_views/includes/date_views.views.inc
Implements hook_views_data()

File

date_views/date_views.module, line 98

Code

function date_views_base_tables() {
  $base_tables =& drupal_static(__FILE__, array());
  if (empty($base_tables)) {

    // First we get the base tables we can learn about from entity_info.
    $entity_info = entity_get_info();
    foreach ($entity_info as $entity_type => $info) {
      if (!empty($info['base table'])) {
        $base_tables[$info['base table']] = $entity_type;
      }
      if (!empty($info['revision table'])) {
        $base_tables[$info['revision table']] = $entity_type;
      }
    }

    // Then we let other modules tell us about other entity tables that hold date fields.
    $base_tables += module_invoke_all('date_views_extra_tables');
  }
  return $base_tables;
}