localized date range format

This commit is contained in:
2018-05-15 12:16:40 +02:00
parent f9ca27e425
commit 9ab88168f6
6 changed files with 26 additions and 16 deletions
@@ -55,8 +55,14 @@ class EntityReferenceLabelFormatterAjax extends EntityReferenceLabelFormatter {
public function viewElements(FieldItemListInterface $items, $langcode) {
$elements = [];
$output_as_link = $this->getSetting('link');
$current_langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
foreach ($this->getEntitiesToView($items, $langcode) as $delta => $entity) {
if ($entity->hasTranslation($current_langcode)) {
$entity = $entity->getTranslation($current_langcode);
}
$label = $entity->label();
// If the link is to be displayed and the entity has a uri, display a
// link.