Skip to content
Snippets Groups Projects

adding <none> to link field when entity does not exist anymore

Files

@@ -76,8 +76,13 @@ protected static function getUriAsDisplayableString($uri) {
// Show the 'entity:' URI as the entity autocomplete would.
// @todo Support entity types other than 'node'. Will be fixed in
// https://www.drupal.org/node/2423093.
if ($entity_type == 'node' && $entity = \Drupal::entityTypeManager()->getStorage($entity_type)->load($entity_id)) {
$displayable_string = EntityAutocomplete::getEntityLabels([$entity]);
if ($entity_type == 'node') {
if ($entity = \Drupal::entityTypeManager()->getStorage($entity_type)->load($entity_id)) {
$displayable_string = EntityAutocomplete::getEntityLabels([$entity]);
}
else {
$displayable_string = '<none>';
}
}
}
elseif ($scheme === 'route') {
Loading