You are here

function sortableviews_views_data_alter in Sortableviews 8

Implements hook_views_data_alter().

File

./sortableviews.module, line 33
Hook implementations for Sortable Views.

Code

function sortableviews_views_data_alter(&$data) {
  foreach (\Drupal::entityTypeManager()
    ->getDefinitions() as $entity_type) {
    $base_table = $entity_type
      ->getDataTable() ?: $entity_type
      ->getBaseTable();
    if ($base_table && isset($data[$base_table]['table'])) {
      $data[$base_table]['sortable_handle'] = [
        'title' => t('Drag and drop handle.'),
        'group' => t('Sortableviews'),
        'help' => t('Provides a handle for drag and drop sorting'),
        'field' => [
          'id' => 'sortable_views_handle',
          'click sortable' => FALSE,
        ],
      ];
      $data[$base_table]['save_sortable_changes'] = [
        'title' => t('Save Sortableviews changes'),
        'help' => t('Saves changes by drag and drop using Sortableviews.'),
        'area' => [
          'id' => 'save_sortable_changes',
        ],
      ];
    }
  }
}