You are here

function tmgmt_smartling_views_pre_view in TMGMT Translator Smartling 8

Same name and namespace in other branches
  1. 8.4 tmgmt_smartling.module \tmgmt_smartling_views_pre_view()
  2. 8.2 tmgmt_smartling.module \tmgmt_smartling_views_pre_view()
  3. 8.3 tmgmt_smartling.module \tmgmt_smartling_views_pre_view()

Implements hook_views_pre_view().

File

./tmgmt_smartling.module, line 118
Contains

Code

function tmgmt_smartling_views_pre_view(ViewExecutable $view, $display_id, array &$args) {
  if ($view
    ->id() === 'tmgmt_translation_all_job_items') {
    $handlers = $view
      ->getHandlers('field');
    foreach ($handlers as $name => $value) {
      $view
        ->removeHandler($view->current_display, 'field', $name);
    }
    $view
      ->addHandler($view->current_display, 'field', 'tmgmt_job_item', 'tmgmt_job_item_bulk_form', array(
      'id' => 'tmgmt_job_item_bulk_form',
      'table' => 'tmgmt_job_item',
      'field' => 'tmgmt_job_item_bulk_form',
      'group_type' => 'group',
      'label' => 'Bulk update',
      'hide_alter_empty' => 1,
      'action_title' => 'With selection',
      'include_exclude' => 'exclude',
      'selected_actions' => [],
      'entity_type' => 'tmgmt_job_item',
      'plugin_id' => 'bulk_form',
      'weight' => -10,
    ));
    foreach ($handlers as $name => $value) {
      $view
        ->addHandler($view->current_display, 'field', 'tmgmt_job_item', $name, $value);
    }
  }
  if ($view
    ->id() === 'tmgmt_job_overview') {
    $handlers = $view
      ->getHandlers('field');
    $view
      ->removeHandler($view->current_display, 'field', 'operations');
    $view
      ->addHandler($view->current_display, 'field', 'tmgmt_job', 'smartling_dashboard', array(
      'id' => 'smartling_dashboard',
      'table' => 'tmgmt_job',
      'field' => 'smartling_dashboard',
      'group_type' => 'group',
      'label' => 'Smartling',
      'hide_alter_empty' => 1,
      'selected_actions' => [],
      'entity_type' => 'tmgmt_job',
      'plugin_id' => 'tmgmt_smartling_dashboard_link',
      'weight' => -10,
    ));
    $view
      ->addHandler($view->current_display, 'field', 'tmgmt_job_item', 'operations', $handlers['operations']);
  }
}