public function NodeGalleryBehaviorHandler::views_data_alter in Node Gallery 7
Overrides views_data_alter().
Overrides EntityReference_BehaviorHandler_Abstract::views_data_alter
File
- plugins/
entityreference/ behavior/ NodeGalleryBehaviorHandler.class.php, line 134 - Node Gallery EntityReference behavior plugin.
Class
- NodeGalleryBehaviorHandler
- Node Gallery behavior handler.
Code
public function views_data_alter(&$data, $field) {
// We need to override the default EntityReference table settings when Node
// Gallery behavior is being used.
if (!empty($field['settings']['handler_settings']['behaviors']['node_gallery_behavior']['status'])) {
$data['node_gallery_relationship'] = array(
'table' => array(
'join' => array(
'node' => array(
'left_field' => 'nid',
'field' => 'nid',
),
),
),
$field['field_name'] => $data['field_data_' . $field['field_name']][$field['field_name']],
$field['field_name'] . '_target_id' => $data['field_data_' . $field['field_name']][$field['field_name'] . '_target_id'],
);
$data['node_gallery_relationship'][$field['field_name']]['field']['table'] = 'node_gallery_relationship';
$data['node_gallery_relationship'][$field['field_name']]['field']['real field'] = 'ngid';
unset($data['node_gallery_relationship'][$field['field_name']]['field']['additional fields']);
foreach (array(
'filter',
'argument',
'sort',
) as $op) {
$data['node_gallery_relationship'][$field['field_name'] . '_target_id'][$op]['field'] = 'ngid';
$data['node_gallery_relationship'][$field['field_name'] . '_target_id'][$op]['table'] = 'node_gallery_relationship';
unset($data['node_gallery_relationship'][$field['field_name'] . '_target_id'][$op]['additional fields']);
}
// Get rid of the original tables.
unset($data['field_data_' . $field['field_name']]);
unset($data['field_revision_' . $field['field_name']]);
}
}