public function HtmlFormatterTrait::getEntityUrl in HTML Formatter 8
Get url from entity.
Parameters
FieldItemListInterface $items: FieldItemListInterface items.
Return value
string $url Entity url or blank if none.
3 calls to HtmlFormatterTrait::getEntityUrl()
- HtmlFieldFormatter::viewElements in src/
Plugin/ Field/ FieldFormatter/ HtmlFieldFormatter.php - Builds a renderable array for a field value.
- HtmlFieldFormatterDateTime::viewElements in src/
Plugin/ Field/ FieldFormatter/ HtmlFieldFormatterDateTime.php - Builds a renderable array for a field value.
- HtmlFieldFormatterTimestamp::viewElements in src/
Plugin/ Field/ FieldFormatter/ HtmlFieldFormatterTimestamp.php - Builds a renderable array for a field value.
File
- src/
Plugin/ HtmlFormatterTrait.php, line 86
Class
Namespace
Drupal\html_formatter\PluginCode
public function getEntityUrl(FieldItemListInterface $items) {
$url = '';
$entity = $items
->getEntity();
if (!$entity
->isNew()) {
if ($entity
->hasLinkTemplate('canonical')) {
$url = $entity
->toUrl('canonical', [
'language' => $entity
->language(),
]);
}
}
return $url;
}