You are here

public function VarDumperBlock::build in VarDumper 8

.

Overrides BlockPluginInterface::build

File

modules/vardumper_block/src/Plugin/Block/VarDumperBlock.php, line 41

Class

VarDumperBlock
Provides a 'Vardumper' block.

Namespace

Drupal\vardumper_block\Plugin\Block

Code

public function build() {
  $items = [];
  foreach ($this->session
    ->getFlashBag()
    ->get('vardumper', []) as $message) {
    $items[] = $message;
  }
  if ($items) {
    return [
      '#theme' => 'item_list',
      '#items' => $items,
      '#cache' => [
        'max-age' => 0,
      ],
    ];
  }
}