You are here

public function ChildEntityWarning::getList in Entity Reference Hierarchy 8.2

Same name and namespace in other branches
  1. 3.x src/Information/ChildEntityWarning.php \Drupal\entity_hierarchy\Information\ChildEntityWarning::getList()

Gets render array for child entity list.

Return value

array Render array.

File

src/Information/ChildEntityWarning.php, line 59

Class

ChildEntityWarning
Defines a value object for a child entity warning.

Namespace

Drupal\entity_hierarchy\Information

Code

public function getList() {
  $child_labels = [];
  $build = [
    '#theme' => 'item_list',
  ];
  foreach ($this->relatedEntities as $node) {
    if (!$this->relatedEntities
      ->contains($node) || $node == $this->parent) {
      continue;
    }
    $child_labels[] = $this->relatedEntities
      ->offsetGet($node)
      ->label();
  }
  $build['#items'] = array_unique($child_labels);
  $this->cache
    ->applyTo($build);
  return $build;
}