civicrm_entity_default_views_controller.inc in CiviCRM Entity 7
File
civicrm_entity_default_views_controller.inc
View source
<?php
class CiviCRMEntityDefaultViewsController extends EntityDefaultViewsController {
public function views_data() {
$data = array();
$this->relationships = array();
if (!empty($this->info['base table'])) {
$table = $this->info['base table'];
$data[$table]['table']['group'] = drupal_ucfirst($this->info['label']);
$data[$table]['table']['entity type'] = $this->type;
$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();
$data += $this->relationships;
}
return $data;
}
protected function schema_fields() {
if (empty($this->info['base table'])) {
return array();
}
$schema = civicrm_entity_get_schema($this->info['base table']);
$properties = entity_get_property_info($this->type) + array(
'properties' => array(),
);
$data = array();
foreach ($properties['properties'] as $name => $property_info) {
if (!empty($property_info['schema field']) && !empty($schema['fields']) && isset($schema['fields'][$property_info['schema field']])) {
if ($views_info = $this
->map_from_schema_info($name, $schema['fields'][$property_info['schema field']], $property_info)) {
$data[$name] = $views_info;
}
}
}
return $data;
}
}