EntityViewController::buildTitle

public EntityViewController::buildTitle(array $page)

Pre-render callback to build the page title.

Parameters

array $page: A page render array.

Return value

array The changed page render array.

File

core/lib/Drupal/Core/Entity/Controller/EntityViewController.php, line 63

Class

EntityViewController
Defines a generic controller to render a single entity.

Namespace

Drupal\Core\Entity\Controller

Code

public function buildTitle(array $page) {
  $entity_type = $page['#entity_type'];
  $entity = $page['#' . $entity_type];
  // If the entity's label is rendered using a field formatter, set the
  // rendered title field formatter as the page title instead of the default
  // plain text title. This allows attributes set on the field to propagate
  // correctly (e.g. RDFa, in-place editing).
  if ($entity instanceof FieldableEntityInterface) {
    $label_field = $entity->getEntityType()->getKey('label');
    if (isset($page[$label_field])) {
      $page['#title'] = $this->renderer->render($page[$label_field]);
    }
  }
  return $page;
}
doc_Drupal
2016-10-29 09:08:50
Comments
Leave a Comment

Please login to continue.