You are here

class ManageDisplayEntityViewController in Manage display 8

Defines a controller to render a single node.

Hierarchy

Expanded class hierarchy of ManageDisplayEntityViewController

File

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

Namespace

Drupal\manage_display_fix_title\Controller
View source
class ManageDisplayEntityViewController extends EntityViewController {

  /**
   * Pre-render callback to build the page title.
   *
   * @param array $page
   *   A page render array.
   *
   * @return array
   *   The changed page render array.
   */
  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;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DeprecatedServicePropertyTrait::__get public function Allows to access deprecated/removed properties.
EntityViewController::$deprecatedProperties protected property
EntityViewController::$entityTypeManager protected property The entity type manager.
EntityViewController::$renderer protected property The renderer service.
EntityViewController::create public static function Instantiates a new instance of this class. Overrides ContainerInjectionInterface::create 2
EntityViewController::trustedCallbacks public static function Lists the trusted callbacks provided by the implementing class. Overrides TrustedCallbackInterface::trustedCallbacks
EntityViewController::view public function Provides a page to render a single entity. 2
EntityViewController::viewRevision public function Provides a page to render a single entity revision.
EntityViewController::__construct public function Creates an EntityViewController object. 2
ManageDisplayEntityViewController::buildTitle public function Pre-render callback to build the page title. Overrides EntityViewController::buildTitle
TrustedCallbackInterface::THROW_EXCEPTION constant Untrusted callbacks throw exceptions.
TrustedCallbackInterface::TRIGGER_SILENCED_DEPRECATION constant Untrusted callbacks trigger silenced E_USER_DEPRECATION errors.
TrustedCallbackInterface::TRIGGER_WARNING constant Untrusted callbacks trigger E_USER_WARNING errors.