You are here

function heartbeat_views_data in Heartbeat 8

Same name and namespace in other branches
  1. 6.4 views/heartbeat_views.views.inc \heartbeat_views_data()
  2. 6.2 user_activity_views/user_activity_views.views.inc \heartbeat_views_data()
  3. 6.3 views/heartbeat_views.views.inc \heartbeat_views_data()
  4. 7 heartbeat.views.inc \heartbeat_views_data()

Implements hook_views_data().

File

./heartbeat.views.inc, line 22
Contains heartbeat\heartbeat.views.inc.. Provide a custom views field data that isn't tied to any other module.

Code

function heartbeat_views_data() {
  $data['views']['table']['group'] = t('Custom Global');
  $data['views']['table']['join'] = array(
    // #global is a special flag which allows a table to appear all the time.
    '#global' => array(),
  );
  $data['views']['heartbeat_message_field'] = array(
    'title' => t('Heartbeat message field'),
    'help' => t('Heartbeat field formatter which allows for rendering of HTML'),
    'field' => array(
      'id' => 'heartbeat_message_field',
    ),
  );

  // Base data.
  $data = [];
  $data['heartbeat_friendship'] = [];
  $data['heartbeat_friendship']['table'] = [];
  $data['heartbeat_friendship']['table']['group'] = t('Heartbeat Friendship');
  $data['heartbeat_friendship']['table']['base'] = [
    'field' => 'id',
    'title' => t('Friendships'),
    'help' => t('Maintains friendship status between Users'),
  ];

  // Fields.
  $data['heartbeat_friendship']['id'] = [
    'title' => t('id'),
    'help' => t('Friendship ID'),
    'field' => [
      'id' => 'numeric',
    ],
    'sort' => array(
      // ID of sort handler plugin to use.
      'id' => 'standard',
    ),
    'filter' => array(
      // ID of filter handler plugin to use.
      'id' => 'numeric',
    ),
    'argument' => array(
      // ID of argument handler plugin to use.
      'id' => 'numeric',
    ),
  ];
  $data['heartbeat_friendship']['uid'] = [
    'title' => t('UID'),
    'help' => t('User\'s Unique ID.'),
    'field' => [
      'id' => 'numeric',
    ],
    'sort' => array(
      // ID of sort handler plugin to use.
      'id' => 'standard',
    ),
    'filter' => array(
      // ID of filter handler plugin to use.
      'id' => 'numeric',
    ),
    'argument' => array(
      // ID of argument handler plugin to use.
      'id' => 'numeric',
    ),
    'relationship' => array(
      'title' => t('User'),
      'help' => t(''),
      'base' => 'users_field_data',
      'base field' => 'uid',
      'id' => 'standard',
    ),
  ];
  $data['heartbeat_friendship']['uid_target'] = [
    'title' => t('UID Target'),
    'help' => t('Unique ID of the User who is the target of the relationship'),
    'field' => [
      'id' => 'numeric',
    ],
    'sort' => array(
      // ID of sort handler plugin to use.
      'id' => 'standard',
    ),
    'filter' => array(
      // ID of filter handler plugin to use.
      'id' => 'numeric',
    ),
    'argument' => array(
      // ID of argument handler plugin to use.
      'id' => 'numeric',
    ),
    'relationship' => array(
      'title' => t('User Target'),
      'help' => t(''),
      'base' => 'users_field_data',
      'base field' => 'uid',
      'id' => 'standard',
    ),
  ];
  $data['heartbeat_friendship']['status'] = [
    'title' => t('Status'),
    'help' => t('The status of the friendship'),
    'field' => [
      'id' => 'numeric',
    ],
    'sort' => array(
      // ID of sort handler plugin to use.
      'id' => 'standard',
    ),
    'filter' => array(
      // ID of filter handler plugin to use.
      'id' => 'numeric',
    ),
    'argument' => array(
      // ID of argument handler plugin to use.
      'id' => 'numeric',
    ),
  ];
  $data['heartbeat_friendship']['table']['join'] = [
    'users_field_data' => [
      'left_field' => 'uid',
      'field' => 'uid',
    ],
  ];
  return $data;
}