protected function Sql::adjustJoin in Drupal 8
Same name and namespace in other branches
- 9 core/modules/views/src/Plugin/views/query/Sql.php \Drupal\views\Plugin\views\query\Sql::adjustJoin()
Fix a join to adhere to the proper relationship; the left table can vary based upon what relationship items are joined in on.
5 calls to Sql::adjustJoin()
- Sql::addRelationship in core/
modules/ views/ src/ Plugin/ views/ query/ Sql.php - A relationship is an alternative endpoint to a series of table joins. Relationships must be aliases of the primary table and they must join either to the primary table or to a pre-existing relationship.
- Sql::addTable in core/
modules/ views/ src/ Plugin/ views/ query/ Sql.php - Add a table to the query, ensuring the path exists.
- Sql::ensurePath in core/
modules/ views/ src/ Plugin/ views/ query/ Sql.php - Make sure that the specified table can be properly linked to the primary table in the JOINs. This function uses recursion. If the tables needed to complete the path back to the primary table are not in the query they will be added, but additional…
- Sql::ensureTable in core/
modules/ views/ src/ Plugin/ views/ query/ Sql.php - Ensure a table exists in the queue; if it already exists it won't do anything, but if it doesn't it will add the table queue. It will ensure a path leads back to the relationship table.
- Sql::queueTable in core/
modules/ views/ src/ Plugin/ views/ query/ Sql.php - Add a table to the query without ensuring the path.
File
- core/
modules/ views/ src/ Plugin/ views/ query/ Sql.php, line 712
Class
- Sql
- Views query plugin for an SQL query.
Namespace
Drupal\views\Plugin\views\queryCode
protected function adjustJoin($join, $relationship) {
if (!empty($join->adjusted)) {
return $join;
}
if (empty($relationship) || empty($this->relationships[$relationship])) {
return $join;
}
// Adjusts the left table for our relationship.
if ($relationship != $this->view->storage
->get('base_table')) {
// If we're linking to the primary table, the relationship to use will
// be the prior relationship. Unless it's a direct link.
// Safety! Don't modify an original here.
$join = clone $join;
// Do we need to try to ensure a path?
if ($join->leftTable != $this->relationships[$relationship]['table'] && $join->leftTable != $this->relationships[$relationship]['base'] && !isset($this->tables[$relationship][$join->leftTable]['alias'])) {
$this
->ensureTable($join->leftTable, $relationship);
}
// First, if this is our link point/anchor table, just use the relationship
if ($join->leftTable == $this->relationships[$relationship]['table']) {
$join->leftTable = $relationship;
}
elseif (isset($this->tables[$relationship][$join->leftTable]['alias'])) {
$join->leftTable = $this->tables[$relationship][$join->leftTable]['alias'];
}
elseif (isset($this->tableQueue[$relationship]['alias'])) {
$join->leftTable = $this->tableQueue[$relationship]['alias'];
}
}
$join->adjusted = TRUE;
return $join;
}