You are here

protected function ManyToOne::summaryQuery in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Plugin/views/argument/ManyToOne.php \Drupal\views\Plugin\views\argument\ManyToOne::summaryQuery()

Build the info for the summary query.

This must:

  • addGroupBy: group on this field in order to create summaries.
  • addField: add a 'num_nodes' field for the count. Usually it will be a count on $view->base_field
  • setCountField: Reset the count field so we get the right paging.

Return value

The alias used to get the number of records (count) for this entry.

Overrides ArgumentPluginBase::summaryQuery

File

core/modules/views/src/Plugin/views/argument/ManyToOne.php, line 161
Contains \Drupal\views\Plugin\views\argument\ManyToOne.

Class

ManyToOne
An argument handler for use in fields that have a many to one relationship with the table(s) to the left. This adds a bunch of options that are reasonably common with this type of relationship. Definition terms:

Namespace

Drupal\views\Plugin\views\argument

Code

protected function summaryQuery() {
  $field = $this->table . '.' . $this->field;
  $join = $this
    ->getJoin();
  if (!empty($this->options['require_value'])) {
    $join->type = 'INNER';
  }
  if (empty($this->options['add_table']) || empty($this->view->many_to_one_tables[$field])) {
    $this->tableAlias = $this->query
      ->ensureTable($this->table, $this->relationship, $join);
  }
  else {
    $this->tableAlias = $this->helper
      ->summaryJoin();
  }

  // Add the field.
  $this->base_alias = $this->query
    ->addField($this->tableAlias, $this->realField);
  $this
    ->summaryNameField();
  return $this
    ->summaryBasics();
}