Issue #3151609: Use entity title for link text when link text is empty.
2 open threads
Closes #3151609
Merge request reports
Activity
33 35 */ 34 36 protected $pathValidator; 35 37 38 /** 39 * The entity type manager service. 40 * 41 * @var \Drupal\Core\Entity\EntityTypeManagerInterface 42 */ 43 protected $entityTypeManager; changed this line in version 3 of the diff
added 1 commit
180 180 $url = $this->buildUrl($item); 181 181 $link_title = $url->toString(); 182 182 183 // Use the entity title for the link text for internal URLs only. 184 if (empty($settings['url_only']) && !$url->isExternal() && empty($item->title) && $url->isRouted()) { 185 $route_parameters = $url->getRouteParameters(); 186 if (!empty($route_parameters)) { 187 foreach ($route_parameters as $entity_type => $id) { 188 if ($this->entityTypeManager->hasDefinition($entity_type)) { 189 if ($entity = $this->entityTypeManager->getStorage($entity_type)->load($id)) { 190 $translated_entity = $entity->hasTranslation($langcode) ? $entity->getTranslation($langcode) : $entity; Before calling
hasTranslation
we should check if entity is instance ofTranslatableInterface
Edited by Klemen Brodejchanged this line in version 4 of the diff
added 1 commit
Please register or sign in to reply