public ManyToOneHelper::addTable($join = NULL, $alias = NULL)
Add a table to the query.
This is an advanced concept; not only does it add a new instance of the table, but it follows the relationship path all the way down to the relationship link point and adds *that* as a new relationship and then adds the table to the relationship, if necessary.
File
- core/modules/views/src/ManyToOneHelper.php, line 63
Class
- ManyToOneHelper
- This many to one helper object is used on both arguments and filters.
Namespace
Drupal\views
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | public function addTable( $join = NULL, $alias = NULL) { // This is used for lookups in the many_to_one table. $field = $this ->handler->relationship . '_' . $this ->handler->table . '.' . $this ->handler->field; if ( empty ( $join )) { $join = $this ->getJoin(); } // See if there's a chain between us and the base relationship. If so, we need // to create a new relationship to use. $relationship = $this ->handler->relationship; // Determine the primary table to seek if ( empty ( $this ->handler->query->relationships[ $relationship ])) { $base_table = $this ->handler->view->storage->get( 'base_table' ); } else { $base_table = $this ->handler->query->relationships[ $relationship ][ 'base' ]; } // Cycle through the joins. This isn't as error-safe as the normal // ensurePath logic. Perhaps it should be. $r_join = clone $join ; while ( $r_join ->leftTable != $base_table ) { $r_join = HandlerBase::getTableJoin( $r_join ->leftTable, $base_table ); } // If we found that there are tables in between, add the relationship. if ( $r_join ->table != $join ->table) { $relationship = $this ->handler->query->addRelationship( $this ->handler->table . '_' . $r_join ->table, $r_join , $r_join ->table, $this ->handler->relationship); } // And now add our table, using the new relationship if one was used. $alias = $this ->handler->query->addTable( $this ->handler->table, $relationship , $join , $alias ); // Store what values are used by this table chain so that other chains can // automatically discard those values. if ( empty ( $this ->handler->view->many_to_one_tables[ $field ])) { $this ->handler->view->many_to_one_tables[ $field ] = $this ->handler->value; } else { $this ->handler->view->many_to_one_tables[ $field ] = array_merge ( $this ->handler->view->many_to_one_tables[ $field ], $this ->handler->value); } return $alias ; } |
Please login to continue.