- // Convert a single-valued array of values to the single-value case,
- // and transform from IN() notation to = notation
- if (is_array($info['value']) && count($info['value']) == 1) {
- $info['value'] = array_shift($info['value']);
- }
- if (is_array($info['value'])) {
- // We use an SA-CORE-2014-005 conformant placeholder for our array
- // of values. Also, note that the 'IN' operator is implicit.
- // @see https://www.drupal.org/node/2401615.
- $operator = !empty($info['operator']) ? $info['operator'] : 'IN';
- $placeholder = ':views_join_condition_' . $select_query->nextPlaceholder() . '[]';
- $placeholder_sql = "( $placeholder )";
- }
- else {
- // With a single value, the '=' operator is implicit.
- $operator = !empty($info['operator']) ? $info['operator'] : '=';
- $placeholder = $placeholder_sql = ':views_join_condition_' . $select_query->nextPlaceholder();
- }
- // Set 'field' as join table field if available or set 'left field' as
- // join table field is not set.
- if (isset($info['field'])) {
- $join_table_field = "$join_table$info[field]";
- // Allow the value to be set either with the 'value' element or
- // with 'left_field'.
- if (isset($info['left_field'])) {
- $placeholder_sql = "$left[alias].$info[left_field]";
- }
- else {
- $arguments[$placeholder] = $info['value'];
- }
- }
- // Set 'left field' as join table field is not set.
- else {
- $join_table_field = "$left[alias].$info[left_field]";
- $arguments[$placeholder] = $info['value'];
- }
- // Render out the SQL fragment with parameters.
- $extras[] = "$join_table_field $operator $placeholder_sql";
- }
+ $select_query->addJoin($this->type, $right_table, $table['alias'], $condition, $arguments);
+ }
+ /**
+ * Adds the extras to the join condition.
+ *
+ * @param array $arguments
+ * Array of query arguments.
+ * @param string $condition
+ * The condition to be built.
+ * @param array $table
+ * The right table.
+ * @param \Drupal\Core\Database\Query\SelectInterface $select_query
+ * The current select query being built.
+ * @param array $left_table
+ * The left table.
+ */
+ protected function joinAddExtra(&$arguments, &$condition, $table, SelectInterface $select_query, $left_table = NULL) {
+ if (is_array($this->extra)) {
+ $extras = [];
+ foreach ($this->extra as $info) {
+ $extras[] = $this->buildExtra($info, $arguments, $table, $select_query, $left_table);
+ }