function EntityRevisionViewController::title

Same name in other branches
  1. 11.x core/lib/Drupal/Core/Entity/Controller/EntityRevisionViewController.php \Drupal\Core\Entity\Controller\EntityRevisionViewController::title()

Provides a title callback for a revision of an entity.

Parameters

\Drupal\Core\Entity\RevisionableInterface $_entity_revision: The revisionable entity, passed in directly from request attributes.

Return value

\Drupal\Core\StringTranslation\TranslatableMarkup The title for the entity revision view page.

File

core/lib/Drupal/Core/Entity/Controller/EntityRevisionViewController.php, line 91

Class

EntityRevisionViewController
Defines a controller to view an entity revision.

Namespace

Drupal\Core\Entity\Controller

Code

public function title(RevisionableInterface $_entity_revision) : TranslatableMarkup {
    $revision = $this->entityRepository
        ->getTranslationFromContext($_entity_revision);
    $titleArgs = [
        '%title' => $revision->label(),
    ];
    if (!$revision instanceof RevisionLogInterface) {
        return $this->t('Revision of %title', $titleArgs);
    }
    $titleArgs['%date'] = $this->dateFormatter
        ->format($revision->getRevisionCreationTime());
    return $this->t('Revision of %title from %date', $titleArgs);
}

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