protected function SmartDateFormatListBuilder::makeLinksFromRef in Smart Date 8
Same name and namespace in other branches
- 8.2 src/Entity/SmartDateFormatListBuilder.php \Drupal\smart_date\Entity\SmartDateFormatListBuilder::makeLinksFromRef()
 - 3.x src/Entity/SmartDateFormatListBuilder.php \Drupal\smart_date\Entity\SmartDateFormatListBuilder::makeLinksFromRef()
 - 3.0.x src/Entity/SmartDateFormatListBuilder.php \Drupal\smart_date\Entity\SmartDateFormatListBuilder::makeLinksFromRef()
 - 3.1.x src/Entity/SmartDateFormatListBuilder.php \Drupal\smart_date\Entity\SmartDateFormatListBuilder::makeLinksFromRef()
 - 3.2.x src/Entity/SmartDateFormatListBuilder.php \Drupal\smart_date\Entity\SmartDateFormatListBuilder::makeLinksFromRef()
 - 3.3.x src/Entity/SmartDateFormatListBuilder.php \Drupal\smart_date\Entity\SmartDateFormatListBuilder::makeLinksFromRef()
 - 3.4.x src/Entity/SmartDateFormatListBuilder.php \Drupal\smart_date\Entity\SmartDateFormatListBuilder::makeLinksFromRef()
 
Turn a EntityReferenceFieldItemList into a render array of links.
File
- src/
Entity/ SmartDateFormatListBuilder.php, line 45  
Class
- SmartDateFormatListBuilder
 - Defines a class to build a listing of Smart date formats.
 
Namespace
Drupal\smart_date\EntityCode
protected function makeLinksFromRef($ref) {
  // No value means nothing to do.
  if (!$ref) {
    return NULL;
  }
  $entities = $ref
    ->referencedEntities();
  $content = [
    '#theme' => 'item_list',
    '#list_type' => 'ul',
    '#wrapper_attributes' => [
      'class' => 'container',
    ],
  ];
  $links = [];
  foreach ($entities as $ref_entity) {
    $links[] = Link::fromTextAndUrl($ref_entity
      ->getTitle(), $ref_entity
      ->toUrl());
  }
  $content['#items'] = $links;
  return $content;
}