class TurtleLazyBuilder

Same name and namespace in other branches
  1. 10 core/modules/big_pipe/tests/src/Unit/Render/FiberPlaceholderTest.php \Drupal\Tests\big_pipe\Unit\Render\TurtleLazyBuilder

Test class for testing fiber placeholders.

Hierarchy

Expanded class hierarchy of TurtleLazyBuilder

File

core/modules/big_pipe/tests/src/Unit/Render/FiberPlaceholderTest.php, line 116

Namespace

Drupal\Tests\big_pipe\Unit\Render
View source
class TurtleLazyBuilder implements TrustedCallbackInterface {
  
  /**
   * Render API callback: Suspends execution twice to simulate a long operation.
   *
   * This function is assigned as a #lazy_builder callback.
   *
   * @return array
   *   The lazy builder callback.
   */
  public static function turtle() : array {
    if (\Fiber::getCurrent() !== NULL) {
      \Fiber::suspend();
    }
    if (\Fiber::getCurrent() !== NULL) {
      \Fiber::suspend();
    }
    return [
      '#markup' => '<span>Turtle is finally here. But how?</span>',
    ];
  }
  
  /**
   * {@inheritdoc}
   */
  public static function trustedCallbacks() {
    return [
      'turtle',
    ];
  }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
TrustedCallbackInterface::THROW_EXCEPTION constant Untrusted callbacks throw exceptions.
TrustedCallbackInterface::TRIGGER_SILENCED_DEPRECATION constant Untrusted callbacks trigger silenced E_USER_DEPRECATION errors.
TurtleLazyBuilder::trustedCallbacks public static function Lists the trusted callbacks provided by the implementing class. Overrides TrustedCallbackInterface::trustedCallbacks
TurtleLazyBuilder::turtle public static function Render API callback: Suspends execution twice to simulate a long operation.

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