function JoinPluginBase::buildJoin

Same name in other branches
  1. 9 core/modules/views/src/Plugin/views/join/JoinPluginBase.php \Drupal\views\Plugin\views\join\JoinPluginBase::buildJoin()
  2. 8.9.x core/modules/views/src/Plugin/views/join/JoinPluginBase.php \Drupal\views\Plugin\views\join\JoinPluginBase::buildJoin()
  3. 11.x core/modules/views/src/Plugin/views/join/JoinPluginBase.php \Drupal\views\Plugin\views\join\JoinPluginBase::buildJoin()

Overrides JoinPluginInterface::buildJoin

3 methods override JoinPluginBase::buildJoin()
CastedIntFieldJoin::buildJoin in core/modules/views/src/Plugin/views/join/CastedIntFieldJoin.php
Builds the SQL for the join this object represents.
JoinTest::buildJoin in core/modules/views/tests/modules/views_test_data/src/Plugin/views/join/JoinTest.php
Builds the SQL for the join this object represents.
Subquery::buildJoin in core/modules/views/src/Plugin/views/join/Subquery.php
Builds the SQL for the join this object represents.

File

core/modules/views/src/Plugin/views/join/JoinPluginBase.php, line 296

Class

JoinPluginBase
Represents a join and creates the SQL necessary to implement the join.

Namespace

Drupal\views\Plugin\views\join

Code

public function buildJoin($select_query, $table, $view_query) {
    if (empty($this->configuration['table formula'])) {
        $right_table = $this->table;
    }
    else {
        $right_table = $this->configuration['table formula'];
    }
    if ($this->leftTable) {
        $left_table = $view_query->getTableInfo($this->leftTable);
        $left_field = $this->leftFormula ?: "{$left_table['alias']}.{$this->leftField}";
    }
    else {
        // This can be used if left_field is a formula or something. It should be used only *very* rarely.
        $left_field = $this->leftField;
        $left_table = NULL;
    }
    $condition = "{$left_field} " . $this->configuration['operator'] . " {$table['alias']}.{$this->field}";
    $arguments = [];
    // Tack on the extra.
    if (isset($this->extra)) {
        $this->joinAddExtra($arguments, $condition, $table, $select_query, $left_table);
    }
    $select_query->addJoin($this->type, $right_table, $table['alias'], $condition, $arguments);
}

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