function PageContext::getEntityLabel
Retrieves the label of the given entity.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity from which the label will be retrieved.
Return value
string|null The label as a string if available, NULL otherwise.
1 call to PageContext::getEntityLabel()
- PageContext::build in core/
modules/ navigation/ src/ Plugin/ TopBarItem/ PageContext.php - Builds and returns the renderable array for this top bar item plugin.
File
-
core/
modules/ navigation/ src/ Plugin/ TopBarItem/ PageContext.php, line 132
Class
- PageContext
- Provides the Page Context top bar item.
Namespace
Drupal\navigation\Plugin\TopBarItemCode
protected function getEntityLabel(EntityInterface $entity) : ?string {
$label = $entity->label();
if (is_string($label)) {
return $label;
}
if ($label instanceof \Stringable) {
return (string) $label;
}
return NULL;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.