You are here

public function PrerenderList::renderItems in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views/src/Plugin/views/field/PrerenderList.php \Drupal\views\Plugin\views\field\PrerenderList::renderItems()
  2. 9 core/modules/views/src/Plugin/views/field/PrerenderList.php \Drupal\views\Plugin\views\field\PrerenderList::renderItems()

Render all items in this field together.

Parameters

array $items: The items provided by getItems for a single row.

Return value

string The rendered items.

Overrides MultiItemsFieldHandlerInterface::renderItems

File

core/modules/views/src/Plugin/views/field/PrerenderList.php, line 74

Class

PrerenderList
Field handler to provide a list of items.

Namespace

Drupal\views\Plugin\views\field

Code

public function renderItems($items) {
  if (!empty($items)) {
    if ($this->options['type'] == 'separator') {
      $render = [
        '#type' => 'inline_template',
        '#template' => '{{ items|safe_join(separator) }}',
        '#context' => [
          'items' => $items,
          'separator' => $this
            ->sanitizeValue($this->options['separator'], 'xss_admin'),
        ],
      ];
    }
    else {
      $render = [
        '#theme' => 'item_list',
        '#items' => $items,
        '#title' => NULL,
        '#list_type' => $this->options['type'],
      ];
    }
    return \Drupal::service('renderer')
      ->render($render);
  }
}