Fetches a handler to join one table to a primary table from the data cache.
string $table: The table to join from.
string $base_table: The table to join to.
Drupal\views\Plugin\views\join\JoinPluginBase
public static function getTableJoin($table, $base_table) {
$data = Views::viewsData()
->get($table);
if (isset($data['table']['join'][$base_table])) {
$join_info = $data['table']['join'][$base_table];
if (!empty($join_info['join_id'])) {
$id = $join_info['join_id'];
}
else {
$id = 'standard';
}
$configuration = $join_info;
// Fill in some easy defaults.
if (empty($configuration['table'])) {
$configuration['table'] = $table;
}
// If this is empty, it's a direct link.
if (empty($configuration['left_table'])) {
$configuration['left_table'] = $base_table;
}
if (isset($join_info['arguments'])) {
foreach ($join_info['arguments'] as $key => $argument) {
$configuration[$key] = $argument;
}
}
$join = Views::pluginManager('join')
->createInstance($id, $configuration);
return $join;
}
}