You are here

public function RealisticDummyContentRecipe::newEntities in Realistic Dummy Content 3.x

Same name and namespace in other branches
  1. 8.2 api/src/includes/RealisticDummyContentRecipe.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentRecipe::newEntities()
  2. 7.2 api/src/includes/RealisticDummyContentRecipe.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentRecipe::newEntities()

Create new entities.

File

api/src/includes/RealisticDummyContentRecipe.php, line 125

Class

RealisticDummyContentRecipe
Abstract base "recipe" class.

Namespace

Drupal\realistic_dummy_content_api\includes

Code

public function newEntities($type, $bundle, $count, $more = []) {
  self::startTime([
    $type,
    $bundle,
    $count,
  ]);
  if ($generator = self::getGenerator($type, $bundle, $count, $more)) {
    $generator
      ->generate();
  }
  else {
    self::$log
      ->error($this
      ->t('Could not find a generator for @type @bundle.', [
      '@type' => $type,
      '@bundle' => $bundle,
    ]));
  }
  $time = self::stopTime([
    $type,
    $bundle,
    $count,
  ]);
  self::$log
    ->log($this
    ->t('@type @bundle: @n created in @time milliseconds', [
    '@type' => $type,
    '@bundle' => $bundle,
    '@n' => $count,
    '@time' => $time,
  ]));
}