1.20.x views_handler_field_bulk_form.inc protected views_handler_field_bulk_form::get_entity_type()

Determine the base table of the bulk operation field.

File

modules/views/handlers/views_handler_field_bulk_form.inc, line 224
Definition of views_handler_field_bulk_form.

Class

views_handler_field_bulk_form
Defines a actions-based bulk operation form element.

Code

protected function get_entity_type() {
  $base_table = $this->view->base_table;

  // If the current field is under a relationship you can't be sure that the
  // base table of the view is the base table of the current field.
  // For example a field from a node author on a node view does have users as base table.
  if (!empty($this->options['relationship']) && $this->options['relationship'] != 'none') {
    $relationships = $this->view->display_handler->get_option('relationships');
    $options = $relationships[$this->options['relationship']];
    $data = views_fetch_data($options['table']);
    $base_table = $data[$options['field']]['relationship']['base'];
  }
  // The base table is now known, use it to determine the entity type.
  foreach (entity_get_info() as $entity_type => $info) {
    if (isset($info['base table']) && $info['base table'] == $base_table) {
      return $entity_type;
    }
    elseif (isset($info['revision table']) && $info['revision table'] == $base_table) {
      $this->revision = TRUE;
      return $entity_type;
    }
  }
  return FALSE;
}