You are here

protected function ViewsDelimitedList::hasDelimiter in Views Delimited List 2.x

Check if this needs delimiter.

Parameters

int $row_index: The index of the row.

Return value

bool[] The has delimiter value.

1 call to ViewsDelimitedList::hasDelimiter()
ViewsDelimitedList::getDelimiters in src/ViewsDelimitedList.php
Gets the delimiters.

File

src/ViewsDelimitedList.php, line 83

Class

ViewsDelimitedList
Logic for separator, delimiters, and conjunctives.

Namespace

Drupal\views_delimited_list

Code

protected function hasDelimiter($row_index) {
  $current_row_index = $row_index + 1;
  $is_second_last_item = $current_row_index == $this->count - 1;
  $last_delimiter = in_array($this->separator, [
    'both',
    'delimiter',
  ], TRUE);
  if ($current_row_index < $this->count - 1 || $is_second_last_item && $last_delimiter) {
    return TRUE;
  }
  return FALSE;
}