function BigPipeTestController::piggy

Same name in other branches
  1. 10 core/modules/big_pipe/tests/modules/big_pipe_test/src/BigPipeTestController.php \Drupal\big_pipe_test\BigPipeTestController::piggy()

#lazy_builder callback; suspends its own execution then returns markup.

Return value

array

File

core/modules/big_pipe/tests/modules/big_pipe_test/src/BigPipeTestController.php, line 145

Class

BigPipeTestController
Returns responses for Big Pipe routes.

Namespace

Drupal\big_pipe_test

Code

public static function piggy() : array {
    // Immediately call Fiber::suspend(), so that other placeholders are
    // executed next. When this is resumed, it will immediately return the
    // render array.
    if (\Fiber::getCurrent() !== NULL) {
        \Fiber::suspend();
    }
    return [
        '#markup' => '<span>This 🐷 little 🐽 piggy 🐖 stayed 🐽 at 🐷 home.</span>',
        '#cache' => [
            'max-age' => 0,
        ],
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.