You are here

public function EntityField::renderItems in Drupal 9

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

Render all items in this field together.

When using advanced render, each possible item in the list is rendered individually. Then the items are all pasted together.

Overrides MultiItemsFieldHandlerInterface::renderItems

File

core/modules/views/src/Plugin/views/field/EntityField.php, line 696

Class

EntityField
A field that displays entity field data.

Namespace

Drupal\views\Plugin\views\field

Code

public function renderItems($items) {
  if (!empty($items)) {
    if ($this->options['multi_type'] == 'separator' || !$this->options['group_rows']) {
      $separator = $this->options['multi_type'] == 'separator' ? Xss::filterAdmin($this->options['separator']) : '';
      $build = [
        '#type' => 'inline_template',
        '#template' => '{{ items | safe_join(separator) }}',
        '#context' => [
          'separator' => $separator,
          'items' => $items,
        ],
      ];
    }
    else {
      $build = [
        '#theme' => 'item_list',
        '#items' => $items,
        '#title' => NULL,
        '#list_type' => $this->options['multi_type'],
      ];
    }
    return $this->renderer
      ->render($build);
  }
}