function ManyToOneHelper::summaryJoin

Same name and namespace in other branches
  1. 9 core/modules/views/src/ManyToOneHelper.php \Drupal\views\ManyToOneHelper::summaryJoin()
  2. 8.9.x core/modules/views/src/ManyToOneHelper.php \Drupal\views\ManyToOneHelper::summaryJoin()
  3. 11.x core/modules/views/src/ManyToOneHelper.php \Drupal\views\ManyToOneHelper::summaryJoin()

Provides the proper join for summary queries.

This is important in part because it will cooperate with other arguments if possible.

File

core/modules/views/src/ManyToOneHelper.php, line 136

Class

ManyToOneHelper
This many to one helper object is used on both arguments and filters.

Namespace

Drupal\views

Code

public function summaryJoin() {
  $field = $this->handler->relationship . '_' . $this->handler->table . '.' . $this->handler->field;
  $join = $this->getJoin();
  // Shortcuts
  $options = $this->handler->options;
  $view = $this->handler->view;
  $query = $this->handler->query;
  if (!empty($options['require_value'])) {
    $join->type = 'INNER';
  }
  if (empty($options['add_table']) || empty($view->many_to_one_tables[$field])) {
    return $query->ensureTable($this->handler->table, $this->handler->relationship, $join);
  }
  else {
    if (!empty($view->many_to_one_tables[$field])) {
      foreach ($view->many_to_one_tables[$field] as $value) {
        $join->extra = [
          [
            'field' => $this->handler->realField,
            'operator' => '!=',
            'value' => $value,
            'numeric' => !empty($this->handler->definition['numeric']),
          ],
        ];
      }
    }
    return $this->addTable($join);
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.