class NodePreviewController extends EntityViewController (View source)

Defines a controller to render a single node in preview.

Properties

protected EntityTypeManagerInterface $entityTypeManager

The entity type manager.

from  EntityViewController
protected RendererInterface $renderer

The renderer service.

from  EntityViewController
protected EntityRepositoryInterface $entityRepository

The entity repository service.

Methods

__construct(EntityTypeManagerInterface $entity_type_manager, RendererInterface $renderer, EntityRepositoryInterface $entity_repository)

Creates a NodeViewController object.

static 
create(ContainerInterface $container)

Instantiates a new instance of this class.

array
buildTitle(array $page)

Pre-render callback to build the page title.

array
view(EntityInterface $node_preview, $view_mode_id = 'full', $langcode = NULL)

Provides a page to render a single entity.

static string[]
trustedCallbacks()

Lists the trusted callbacks provided by the implementing class.

array
viewRevision(EntityInterface $_entity_revision, string $view_mode = 'full')

Provides a page to render a single entity revision.

string
title(EntityInterface $node_preview)

The _title_callback for the page that renders a single node in preview.

Details

__construct(EntityTypeManagerInterface $entity_type_manager, RendererInterface $renderer, EntityRepositoryInterface $entity_repository)

Creates a NodeViewController object.

Parameters

EntityTypeManagerInterface $entity_type_manager

The entity type manager.

RendererInterface $renderer

The renderer service.

EntityRepositoryInterface $entity_repository

The entity repository.

static create(ContainerInterface $container)

Instantiates a new instance of this class.

This is a factory method that returns a new instance of this class. The factory should pass any needed dependencies into the constructor of this class, but not the container itself. Every call to this method must return a new instance of this class; that is, it may not implement a singleton.

Parameters

ContainerInterface $container

The service container this instance should use.

array 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.

array view(EntityInterface $node_preview, $view_mode_id = 'full', $langcode = NULL)

Provides a page to render a single entity.

Parameters

EntityInterface $node_preview
$view_mode_id
$langcode

Return Value

array

A render array as expected by \Drupal\Core\Render\RendererInterface::render().

static string[] trustedCallbacks()

Lists the trusted callbacks provided by the implementing class.

Trusted callbacks are public methods on the implementing class and can be invoked via \Drupal\Core\Security\DoTrustedCallbackTrait::doTrustedCallback().

Return Value

string[]

List of method names implemented by the class that can be used as trusted callbacks.

array viewRevision(EntityInterface $_entity_revision, string $view_mode = 'full')

Provides a page to render a single entity revision.

Parameters

EntityInterface $_entity_revision

The Entity to be rendered. Note this variable is named $_entity_revision rather than $entity to prevent collisions with other named placeholders in the route.

string $view_mode

(optional) The view mode that should be used to display the entity. Defaults to 'full'.

Return Value

array

A render array.

string title(EntityInterface $node_preview)

The _title_callback for the page that renders a single node in preview.

Parameters

EntityInterface $node_preview

The current node.

Return Value

string

The page title.