You are here

public function ManageDisplayEntityViewController::buildTitle in Manage display 8

Pre-render callback to build the page title.

Parameters

array $page: A page render array.

Return value

array The changed page render array.

Overrides EntityViewController::buildTitle

File

modules/manage_display_fix_title/src/Controller/ManageDisplayEntityViewController.php, line 22

Class

ManageDisplayEntityViewController
Defines a controller to render a single node.

Namespace

Drupal\manage_display_fix_title\Controller

Code

public function buildTitle(array $page) {
  $entity_type = $page['#entity_type'];
  $entity = $page['#' . $entity_type];
  if ($entity instanceof FieldableEntityInterface) {
    $label_field = $entity
      ->getEntityType()
      ->getKey('label');
    $page_title = [
      '#theme' => 'entity_page_title',
      '#title' => $entity
        ->label(),
      '#entity' => $entity,
      '#view_mode' => $page['#view_mode'],
    ];
    $page['#title'] = $this->renderer
      ->render($page_title);
    unset($page[$label_field]);
  }
  return $page;
}