You are here

public function ItemList::getString in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php \Drupal\Core\TypedData\Plugin\DataType\ItemList::getString()
  2. 10 core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php \Drupal\Core\TypedData\Plugin\DataType\ItemList::getString()

Returns a string representation of the data.

Return value

string The string representation of the data.

Overrides TypedData::getString

File

core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php, line 87

Class

ItemList
A generic list class.

Namespace

Drupal\Core\TypedData\Plugin\DataType

Code

public function getString() {
  $strings = [];
  foreach ($this->list as $item) {
    $strings[] = $item
      ->getString();
  }

  // Remove any empty strings resulting from empty items.
  return implode(', ', array_filter($strings, 'mb_strlen'));
}