You are here

public function CiviCRMEntityDefaultViewsController::views_data in CiviCRM Entity 7.2

Same name and namespace in other branches
  1. 7 civicrm_entity_default_views_controller.inc \CiviCRMEntityDefaultViewsController::views_data()

Defines the result for hook_views_data().

Overrides EntityDefaultViewsController::views_data

File

./civicrm_entity_default_views_controller.inc, line 11

Class

CiviCRMEntityDefaultViewsController
@TODO Document this class.

Code

public function views_data() {
  $data = array();
  $this->relationships = array();
  if (!empty($this->info['base table'])) {
    $table = $this->info['base table'];

    // Define the base group of this table. Fields that don't
    // have a group defined will go into this field by default.
    $data[$table]['table']['group'] = drupal_ucfirst($this->info['label']);
    $data[$table]['table']['entity type'] = $this->type;

    // If the plural label isn't available, use the regular label.
    $label = isset($this->info['plural label']) ? $this->info['plural label'] : $this->info['label'];
    $data[$table]['table']['base'] = array(
      'field' => $this->info['entity keys']['id'],
      'title' => drupal_ucfirst($label),
      'help' => isset($this->info['description']) ? $this->info['description'] : '',
    );
    $data[$table]['table']['entity type'] = $this->type;
    $data[$table] += $this
      ->schema_fields();

    // Add in any reverse-relationships which have been determined.
    $data += $this->relationships;
  }
  return $data;
}