You are here

function draggableviews_views_query_alter in DraggableViews 8

Same name and namespace in other branches
  1. 6.3 views/draggableviews.views.inc \draggableviews_views_query_alter()
  2. 7 views/draggableviews.views.inc \draggableviews_views_query_alter()

Implements hook_views_query_alter().

File

./draggableviews.module, line 226
Contains draggableviews.module.

Code

function draggableviews_views_query_alter(ViewExecutable $view, QueryPluginBase $query) {

  // Add additional `join condition` for fixing table join.
  // Cannot add it in the draggableviews_views_data_alter because we need view
  // data.
  if ($query instanceof Sql && isset($query
    ->getTableQueue()['draggableviews_structure'])) {

    /** @var \Drupal\views\Plugin\views\join\Standard $join */
    $join = $query
      ->getTableQueue()['draggableviews_structure']['join'];
    $join->extra = [
      [
        'field' => 'view_name',
        'operator' => '=',
        'value' => $view
          ->id(),
        'numeric' => FALSE,
      ],
      [
        'field' => 'view_display',
        'operator' => '=',
        'value' => $view->current_display,
        'numeric' => FALSE,
      ],
    ];
  }
}