function _efq_views_get_property_handlers in EntityFieldQuery Views Backend 7
Helper for efq_views_views_data() Returns the property data.
Parameters
$entity_type Entity type for which the properties are being loaded.:
$info Entity info array for the given entity type.:
1 call to _efq_views_get_property_handlers()
- efq_views_views_data in ./
efq_views.views.inc - Implements hook_views_data().
File
- ./
efq_views.views.inc, line 290
Code
function _efq_views_get_property_handlers(&$views_data, $property, $metadata, $entity_info) {
$move = FALSE;
if (!isset($metadata['properties'][$property])) {
return;
}
$property_info = $metadata['properties'][$property];
// Check whether this field is queryable.
if (empty($property_info['schema field']) && empty($property_info['query callback']) && !empty($property_info['queryable'])) {
return $move;
}
// Avoid generating a million notices.
$property_info += array(
'type' => '',
);
$filter = '';
$argument = '';
// Identify likely handlers for each property, based on property type.
switch ($property_info['type']) {
case 'integer':
case 'decimal':
case 'duration':
$filter = 'efq_views_handler_filter_property_numeric';
$argument = 'efq_views_handler_argument_property_numeric';
break;
case 'boolean':
// Views proper doesn't let boolean fields have argument handlers,
// so we do not support that for properties. (Boolean field API
// fields are actually stored as an integer so that will work.)
$filter = 'efq_views_handler_filter_property_boolean';
break;
case 'date':
$filter = 'efq_views_handler_filter_property_date';
break;
case 'token':
case 'text':
case 'uri':
if (isset($property_info['options list'])) {
$filter = 'efq_views_handler_filter_property_in_operator';
$argument = 'efq_views_handler_argument_property_string';
break;
}
$filter = 'efq_views_handler_filter_property_string';
$argument = 'efq_views_handler_argument_property_string';
break;
case 'taxonomy_vocabulary':
$move = 'vid';
$filter = 'efq_views_handler_filter_property_taxonomy_vocabulary';
$argument = 'efq_views_handler_argument_property_numeric';
}
if ($filter) {
$views_data['filter'] = array(
'handler' => $filter,
'options callback' => isset($property_info['options list']) ? $property_info['options list'] : NULL,
);
}
if ($argument) {
$views_data['argument'] = array(
'handler' => $argument,
);
}
// Assume a queryable property is sortable also.
$views_data['field']['click sortable'] = TRUE;
$views_data['sort']['handler'] = 'efq_views_handler_sort_property';
// To add support for custom handlers, we need to know if the property is
// local or remote. In the latter case, the property info is stored elsewhere.
if (isset($property_info['remote_property'])) {
$property_info = $metadata['properties']['entity_data']['property info'][$property];
}
// Add additional or different custom handlers which are specified by the
// entity metadata.
if (isset($property_info['views'])) {
$views_data = array(
'group' => $entity_info['label'],
'title' => $property_info['label'],
'help' => $property_info['description'],
);
// Add the field handler if it's set.
if (isset($property_info['views']['field'])) {
$views_data['field'] = array(
'click sortable' => FALSE,
'handler' => $property_info['views']['field'],
);
}
// Add the filter handler if it's set.
if (isset($property_info['views']['filter'])) {
$views_data['filter'] = array(
'handler' => $property_info['views']['filter'],
);
}
// Add the contextual filter (argument) handler if it's set.
if (isset($property_info['views']['argument'])) {
$views_data['argument'] = array(
'handler' => $property_info['views']['argument'],
);
}
// Add the sort handler if it's set.
if (isset($property_info['views']['sort'])) {
$views_data['sort'] = array(
'handler' => $property_info['views']['sort'],
);
}
}
return $move;
}