public function EntityPagerLink::getLink in Entity Pager 8
Same name and namespace in other branches
- 2.0.x src/EntityPagerLink.php \Drupal\entity_pager\EntityPagerLink::getLink()
Returns a render array for the link.
Return value
array A render array for the link
Overrides EntityPagerLinkInterface::getLink
File
- src/
EntityPagerLink.php, line 46
Class
- EntityPagerLink
- A class representing a single Entity Pager link.
Namespace
Drupal\entity_pagerCode
public function getLink() {
if (empty($this->entity)) {
return $this
->noResult();
}
$langcode = \Drupal::languageManager()
->getCurrentLanguage()
->getId();
$entity = $this->entity;
if ($entity instanceof TranslatableInterface && $entity
->hasTranslation($langcode)) {
$entity = $entity
->getTranslation($langcode);
}
return [
'#type' => 'link',
'#title' => [
'#markup' => $this->text,
],
'#url' => $entity
->toUrl('canonical'),
];
}