You are here

public function DefaultController::preview in Hierarchical Term Formatter 8

Provides a page to render a single entity.

Parameters

\Drupal\node\NodeInterface $node: The node to be rendered.

\Drupal\Core\Entity\EntityDisplayModeInterface $view_mode: The view mode that should be used to display the entity.

Return value

array A render array as expected by drupal_render().

1 string reference to 'DefaultController::preview'
hierarchical_term_formatter_test.routing.yml in tests/modules/hierarchical_term_formatter_test/hierarchical_term_formatter_test.routing.yml
tests/modules/hierarchical_term_formatter_test/hierarchical_term_formatter_test.routing.yml

File

tests/modules/hierarchical_term_formatter_test/src/Controller/DefaultController.php, line 26

Class

DefaultController
Controller used for previewing nodes in a view mode.

Namespace

Drupal\hierarchical_term_formatter_test\Controller

Code

public function preview(NodeInterface $node, EntityDisplayModeInterface $view_mode) {
  if ($view_mode
    ->getTargetType() == 'node') {
    preg_match('/\\.(.*)/', $view_mode
      ->id(), $matches);
    return parent::view($node, $matches[1]);
  }
  throw new NotFoundHttpException();
}