You are here

public function EntityField::renderItems in Drupal 8

Same name and namespace in other branches
  1. 9 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 708

Class

EntityField
A field that displays entity field data.

Namespace

Drupal\views\Plugin\views\field

Code

public function renderItems($items) {
  if (!empty($items)) {
    $items = $this
      ->prepareItemsByDelta($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);
  }
}