function PageContext::getBadgeLabel

Retrieves the badge label for the given entity.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity for which the label is being retrieved.

Return value

string|null The translated status if available. NULL otherwise. The status if available. NULL otherwise.

1 call to PageContext::getBadgeLabel()
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 124

Class

PageContext
Provides the Page Context top bar item.

Namespace

Drupal\navigation\Plugin\TopBarItem

Code

protected function getBadgeLabel(EntityInterface $entity) : ?string {
    if (!$entity instanceof EntityPublishedInterface) {
        return NULL;
    }
    return (string) ($entity->isPublished() ? $this->t('Published') : $this->t('Unpublished'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.