You are here

public function DescriptionTemplateTrait::description in Examples for Developers 8

Same name and namespace in other branches
  1. 3.x src/Utility/DescriptionTemplateTrait.php \Drupal\examples\Utility\DescriptionTemplateTrait::description()

Generate a render array with our templated content.

Return value

array A render array.

2 calls to DescriptionTemplateTrait::description()
MenuExampleController::basicInstructions in menu_example/src/Controller/MenuExampleController.php
Page callback for the simplest introduction menu entry.
RobotListBuilder::render in config_entity_example/src/Controller/RobotListBuilder.php
Adds some descriptive text to our entity list.

File

src/Utility/DescriptionTemplateTrait.php, line 34

Class

DescriptionTemplateTrait
Trait to implement a "drop-in" template for Example's controllers.

Namespace

Drupal\examples\Utility

Code

public function description() {
  $template_path = $this
    ->getDescriptionTemplatePath();
  $template = file_get_contents($template_path);
  $build = [
    'description' => [
      '#type' => 'inline_template',
      '#template' => $template,
      '#context' => $this
        ->getDescriptionVariables(),
    ],
  ];
  return $build;
}