You are here

function _efq_views_get_entity_data in EntityFieldQuery Views Backend 7

Helper for efq_views_views_data() Returns all possible entity metadata variants (entity_id, revision_id, entity_type, bundle).

Parameters

string $entity_type The selected entity type, if any.:

array $info Entity info array.:

1 call to _efq_views_get_entity_data()
efq_views_views_data in ./efq_views.views.inc
Implements hook_views_data().

File

./efq_views.views.inc, line 93

Code

function _efq_views_get_entity_data($entity_type, $info) {
  $data['entity_id'] = array(
    'group' => t('Entity'),
    'title' => t('Entity ID'),
    'help' => t('The entity ID of the entity.'),
    'field' => array(
      'click sortable' => TRUE,
      'handler' => 'efq_views_handler_field_entity',
    ),
    'filter' => array(
      'handler' => 'efq_views_handler_filter_entity_integer',
    ),
    'sort' => array(
      'handler' => 'efq_views_handler_sort_entity',
    ),
    'argument' => array(
      'handler' => 'efq_views_handler_argument_entity_integer',
    ),
  );
  $data['revision_id'] = array(
    'group' => t('Entity'),
    'title' => t('Revision ID'),
    'help' => t('The revision ID of the entity revision.'),
    'field' => array(
      'click sortable' => TRUE,
      'handler' => 'efq_views_handler_field_entity',
    ),
    'filter' => array(
      'handler' => 'efq_views_handler_filter_entity_integer',
    ),
    'sort' => array(
      'handler' => 'efq_views_handler_sort_entity',
    ),
    'argument' => array(
      'handler' => 'efq_views_handler_argument_entity_integer',
    ),
  );
  if ($entity_type != 'comment' && $entity_type != 'taxonomy_term') {
    $data['bundle'] = array(
      'group' => t('Entity'),
      'title' => t('Bundle'),
      'help' => t('The entity bundle (for example, "article", "page", etc for nodes).'),
      'field' => array(
        'click sortable' => TRUE,
        'handler' => 'efq_views_handler_field_entity',
      ),
      'filter' => array(
        'entity_type' => $entity_type,
        'handler' => 'efq_views_handler_filter_entity_bundle',
      ),
      'sort' => array(
        'handler' => 'efq_views_handler_sort_entity',
      ),
      'argument' => array(
        'handler' => 'efq_views_handler_argument_entity_bundle',
      ),
    );
  }
  $data['bundle_label'] = array(
    'group' => t('Entity'),
    'title' => t('Bundle label'),
    'help' => t('The entity bundle label (for example, "Article", "Basic page", etc for nodes).'),
    'field' => array(
      'click sortable' => FALSE,
      'handler' => 'efq_views_handler_field_entity',
    ),
  );
  $data['label'] = array(
    'group' => t('Entity'),
    'title' => t('Label'),
    'help' => t('The entity label (for example, node title for nodes).'),
    'field' => array(
      'click sortable' => FALSE,
      'handler' => 'efq_views_handler_field_entity_label',
    ),
  );

  // We can only do click sorting and filters/sorts/arguments when the label is
  // stored in the database, instead of being generated in a callback. As
  // labels are not supported by entityCondition/entityOrderBy, treat them as
  // property for filtering and sorting.
  if (isset($info['entity keys']['label']) && !isset($info['label callback'])) {
    $data['label']['field'] = array(
      'click sortable' => TRUE,
      'handler' => 'efq_views_handler_field_entity_label',
      'label column' => $info['entity keys']['label'],
    );
    $data['label']['filter'] = array(
      'handler' => 'efq_views_handler_filter_property_string',
      'field' => $info['entity keys']['label'],
    );
    $data['label']['sort'] = array(
      'handler' => 'efq_views_handler_sort_property',
      'field' => $info['entity keys']['label'],
    );
    $data['label']['argument'] = array(
      'handler' => 'efq_views_handler_argument_property_string',
      'field' => $info['entity keys']['label'],
    );
  }
  return $data;
}