You are here

public function ManageDisplayNodeViewController::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/ManageDisplayNodeViewController.php, line 22

Class

ManageDisplayNodeViewController
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');
    if ($label_field) {
      $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;
}