You are here

function panopoly_magic_get_entity_type in Panopoly Magic 7

Helper function to get the entity type retrieved by a view

1 call to panopoly_magic_get_entity_type()
panopoly_magic_form_views_content_views_panes_content_type_edit_form_alter in ./panopoly_magic.module
Implementation of hook_form_FORM_ID_alter()

File

./panopoly_magic.module, line 1948

Code

function panopoly_magic_get_entity_type($view) {
  $result = 'node';
  if (isset($view->base_table) && $view->base_table != 'node') {

    // Find the entity type with the corresponding base table.
    $base_table = $view->base_table;
    $entity_types = entity_get_info();
    foreach ($entity_types as $entity_type => $entity_type_info) {
      if ($entity_type_info['base table'] == $base_table) {
        $result = $entity_type;
        break;
      }
    }
  }
  return $result;
}