function registration_views_views_data_alter in Entity Registration 7
Same name and namespace in other branches
- 8.2 modules/registration_views/registration_views.module \registration_views_views_data_alter()
- 8 modules/registration_views/registration_views.module \registration_views_views_data_alter()
- 7.2 modules/registration_views/registration_views.module \registration_views_views_data_alter()
Implements hook_views_data_alter().
Create relationships between registrations, and their related entities. Provide additional fields for entities with registrations.
File
- modules/
registration_views/ registration_views.module, line 195 - Entity Registration Views integration
Code
function registration_views_views_data_alter(&$data) {
// Add a state form field option for registrations.
$data['registration']['state_edit'] = array(
'field' => array(
'title' => t('State form field'),
'help' => t('Edit the registration state'),
'handler' => 'RegistrationViewsHandlerStateEdit',
),
);
$registration_instances = registration_get_registration_instances();
$entity_info = entity_get_info();
foreach ($registration_instances as $instance) {
$entity_type = $instance['entity_type'];
$info = $entity_info[$entity_type];
// Entity to Registration.
$data[$info['base table']]['registration_rel'] = array(
'group' => t('Registration'),
'title' => t('@entity to Registration', array(
'@entity' => ucfirst($info['label']),
)),
'help' => t('The Registration associated with the @entity entity.', array(
'@entity' => ucfirst($info['label']),
)),
'relationship' => array(
'entity' => $entity_type,
'handler' => 'registration_handler_relationship',
'label' => t('@entity being the Registration', array(
'@entity' => $entity_type,
)),
'base' => 'registration',
'base field' => 'entity_id',
'relationship field' => $info['entity keys']['id'],
),
);
// Relate entities to registration settings.
$data[$info['base table']]['registration_settings_rel'] = array(
'group' => t('Registration Settings'),
'title' => t('@entity to Registration Settings', array(
'@entity' => ucfirst($info['label']),
)),
'help' => t('The Registration settings associated with the @entity entity.', array(
'@entity' => ucfirst($info['label']),
)),
'relationship' => array(
'entity' => $entity_type,
'handler' => 'registration_handler_relationship',
'label' => t('@entity being the Registration', array(
'@entity' => $entity_type,
)),
'base' => 'registration_entity',
'base field' => 'entity_id',
'relationship field' => $info['entity keys']['id'],
),
);
// Host entity: registration settings link.
$data[$info['base table']]['registration_settings'] = array(
'real field' => $info['entity keys']['id'],
'group' => t('Registration Settings'),
'title' => t('Registration Settings Link'),
'help' => t('Provide a link to edit registration settings for an entity.'),
'field' => array(
'handler' => 'registration_handler_field_entity_settings_link',
),
);
// Host entity: registration status.
$data[$info['base table']]['registration_status'] = array(
'real field' => $info['entity keys']['id'],
'group' => t('Registration Settings'),
'title' => t('Registration Status'),
'help' => t('Show registration status for an entity.'),
'field' => array(
'handler' => 'registration_handler_field_entity_registration_status',
),
);
// Host entity: used slots.
$data[$info['base table']]['capacity_used'] = array(
'real field' => $info['entity keys']['id'],
'group' => t('Registration Settings'),
'title' => t('Spaces used'),
'help' => t('Current number of spaces used for this entity.'),
'field' => array(
'handler' => 'registration_handler_field_entity_capacity_used',
),
);
// Registration to entity.
$data['registration']['registration_related_' . $entity_type] = array(
'group' => t('Registration'),
'title' => t('Registration to @entity', array(
'@entity' => ucfirst($info['label']),
)),
'help' => t('The @entity entity that is associated with the Registration.', array(
'@entity' => $info['label'],
)),
'relationship' => array(
'entity' => $entity_type,
'table' => 'registration',
'handler' => 'registration_handler_relationship',
'label' => t('@entity from Registration', array(
'@entity' => $entity_type,
)),
'base' => $info['base table'],
'base field' => $info['entity keys']['id'],
'relationship field' => 'entity_id',
),
);
}
}