function RandomGeneratorTrait::getRandomGenerator

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/RandomGeneratorTrait.php \Drupal\Tests\RandomGeneratorTrait::getRandomGenerator()
  2. 10 core/tests/Drupal/Tests/RandomGeneratorTrait.php \Drupal\Tests\RandomGeneratorTrait::getRandomGenerator()
  3. 11.x core/tests/Drupal/Tests/RandomGeneratorTrait.php \Drupal\Tests\RandomGeneratorTrait::getRandomGenerator()

Gets the random generator for the utility methods.

Return value

\Drupal\Component\Utility\Random The random generator.

1 call to RandomGeneratorTrait::getRandomGenerator()
JsonApiFunctionalTestBase::createDefaultContent in core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalTestBase.php
Creates default content to test the API.

File

core/tests/Drupal/Tests/RandomGeneratorTrait.php, line 118

Class

RandomGeneratorTrait
Provides random generator utility methods.

Namespace

Drupal\Tests

Code

protected function getRandomGenerator() {
    if (!is_object($this->randomGenerator)) {
        $this->randomGenerator = new Random();
    }
    return $this->randomGenerator;
}

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