function BigPipeTestController::counter
The #lazy_builder callback; returns the current count.
Return value
array The render array.
See also
\Drupal\Tests\big_pipe\Functional\BigPipeTest::testBigPipeMultiOccurrencePlaceholders()
File
- 
              core/modules/ big_pipe/ tests/ modules/ big_pipe_test/ src/ BigPipeTestController.php, line 220 
Class
- BigPipeTestController
- Returns responses for Big Pipe routes.
Namespace
Drupal\big_pipe_testCode
public static function counter() {
  // Lazy builders are not allowed to build their own state like this function
  // does, but in this case we're intentionally doing that for testing
  // purposes: so we can ensure that each lazy builder is only ever called
  // once with the same parameters.
  static $count;
  if (!isset($count)) {
    $count = 0;
  }
  $count++;
  return [
    '#markup' => BigPipeMarkup::create("<p>The count is {$count}.</p>"),
    '#cache' => [
      'max-age' => 0,
    ],
  ];
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
