function notifications_widget_views_data in Notifications widget 8
Implements hook_views_data().
Adds a relationship from the notification table to its' entities.
File
- ./
notifications_widget.module, line 181 - Contains notifications_widget.module.
Code
function notifications_widget_views_data() {
$data['notifications']['table']['group'] = t('Notifications');
$data['notifications']['table']['base'] = [
// This is the identifier field for the view.
'field' => 'id',
'title' => t('Notifications'),
'help' => t('Contains Notifications content and can be related to entity.'),
];
$data['comment_field_data']['notifications']['relationship'] = [
'title' => t('Notifications Comment'),
'label' => t('Notifications with Comment entity'),
'group' => 'Notification',
'help' => t('Reference to the notification of a Comment entity.'),
'id' => 'standard',
'base' => 'notifications',
'base field' => 'entity_id',
'field' => 'cid',
'extra' => [
[
'left_field' => 'comment_type',
'field' => 'bundle',
],
],
];
$data['node_field_data']['notifications']['relationship'] = [
'title' => t('Notifications with entity'),
'label' => t('Notifications with entity'),
'group' => 'Notification',
'help' => t('Reference to the notification of a entity.'),
'id' => 'standard',
'base' => 'notifications',
'base field' => 'entity_id',
'field' => 'nid',
'extra' => [
[
'left_field' => 'type',
'field' => 'bundle',
],
],
];
$data['taxonomy_term_field_data']['notifications']['relationship'] = [
'title' => t('Notifications with term'),
'label' => t('Notifications with term'),
'group' => 'Notification',
'help' => t('Reference to the notification of a term.'),
'id' => 'standard',
'base' => 'notifications',
'base field' => 'entity_id',
'field' => 'tid',
'extra' => [
[
'left_field' => 'vid',
'field' => 'bundle',
],
],
];
$data['profile']['notifications']['relationship'] = [
'title' => t('Notifications with profile'),
'label' => t('Notifications with profile'),
'group' => 'Notification',
'help' => t('Reference to the notification of a profile.'),
'id' => 'standard',
'base' => 'notifications',
'base field' => 'entity_id',
'field' => 'profile_id',
'extra' => [
[
'left_field' => 'type',
'field' => 'bundle',
],
],
];
$data['message']['notifications']['relationship'] = [
'title' => t('Notifications with message'),
'label' => t('Notifications with message'),
'group' => 'Notification',
'help' => t('Reference to the notification of a message.'),
'id' => 'standard',
'base' => 'notifications',
'base field' => 'entity_id',
'field' => 'mid',
'extra' => [
[
'left_field' => 'template',
'field' => 'bundle',
],
],
];
$data['notifications']['user_name'] = [
'title' => t('Notification User name'),
'help' => t('Display name of notification user.'),
'field' => [
'id' => 'markup',
'format' => 'full_html',
],
'filter' => [
'id' => 'string',
],
];
$data['notifications']['bundle'] = [
'title' => t('Notification entity\'s bundles'),
'help' => t('Display name of entity\'s bundles.'),
'field' => [
'id' => 'markup',
'format' => 'full_html',
],
'filter' => [
'id' => 'string',
],
];
$data['notifications']['status'] = [
'title' => t('Notification Status'),
'help' => t('Display status of Notification.'),
'field' => [
'id' => 'numeric',
],
'filter' => [
'id' => 'numeric',
],
];
$data['notifications']['id'] = [
'title' => t('Notification ID'),
'help' => t('Display ID of Notification.'),
'field' => [
'id' => 'numeric',
],
'filter' => [
'id' => 'numeric',
],
];
$data['notifications']['message'] = [
'title' => t('Notification Message'),
'help' => t('Display notification message.'),
'field' => [
'id' => 'markup',
'format' => 'full_html',
],
'filter' => [
'id' => 'string',
],
];
$data['notifications']['entity_id'] = [
'title' => t('Notification entity ID'),
'help' => t('Display entity id of notificaion.'),
'field' => [
'id' => 'numeric',
],
'sort' => [
'id' => 'standard',
],
'filter' => [
'id' => 'numeric',
],
'argument' => [
'id' => 'numeric',
],
];
$data['notifications']['uid'] = [
'title' => t('Notification Author ID'),
'help' => t('Display author name of the notificaion.'),
'field' => [
'id' => 'numeric',
],
'sort' => [
'id' => 'standard',
],
'filter' => [
'id' => 'numeric',
],
'argument' => [
'id' => 'numeric',
],
];
$data['notifications']['created'] = [
'title' => t('Notification Created Date'),
'help' => t('Display notificaion created date.'),
'field' => [
'id' => 'date',
],
'sort' => [
'id' => 'date',
],
'filter' => [
'id' => 'date',
],
];
return $data;
}