You are here

function views_sort_expression_views_post_build in Views Sort Expression 8

Same name and namespace in other branches
  1. 7 views_sort_expression.module \views_sort_expression_views_post_build()

Implements hook_views_post_build().

Remove views_sort_expression from group by if it was configured as a group by manually

Parameters

\Drupal\views\ViewExecutable $view: The view object about to be processed.

See also

\Drupal\views\ViewExecutable

File

./views_sort_expression.module, line 39

Code

function views_sort_expression_views_post_build(ViewExecutable $view) {
  foreach ($view->sort as $handler) {
    if ($handler instanceof ExpressionSort) {
      if ($handler->options['aggregate']) {
        $alias = $handler->realField . '_' . $handler->position;
        $group_by =& $view->build_info['query']
          ->getGroupBy();
        unset($group_by[$alias]);
      }
    }
  }
}