You are here

public function WithArgs::buildJoin in DraggableViews 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/views/join/WithArgs.php \Drupal\draggableviews\Plugin\views\join\WithArgs::buildJoin()

Builds the SQL for the join this object represents.

When possible, try to use table alias instead of table names.

Parameters

$select_query: An select query object.

$table: The base table to join.

\Drupal\views\Plugin\views\query\QueryPluginBase $view_query: The source views query.

Overrides JoinPluginBase::buildJoin

File

src/Plugin/views/join/WithArgs.php, line 19

Class

WithArgs
Defines a join handler with arguments.

Namespace

Drupal\draggableviews\Plugin\views\join

Code

public function buildJoin($select_query, $table, $view_query) {
  $view_args = !empty($view_query->view->args) ? $view_query->view->args : [];
  $context = [
    'select_query' => &$select_query,
    'table' => &$table,
    'view_query' => &$view_query,
  ];
  \Drupal::moduleHandler()
    ->alter('draggableviews_join_withargs', $view_args, $context);
  $view_args = json_encode($view_args);
  if (!isset($this->extra)) {
    $this->extra = [];
  }
  if (is_array($this->extra)) {
    $found = FALSE;
    foreach ($this->extra as $info) {
      if (empty(array_diff(array_keys($info), [
        'field',
        'value',
      ])) && $info['field'] == 'args' && $info['value'] == $view_args) {
        $found = TRUE;
        break;
      }
    }
    if (!$found) {
      $this->extra[] = [
        'field' => 'args',
        'value' => $view_args,
      ];
    }
  }
  parent::buildJoin($select_query, $table, $view_query);
}