You are here

protected function YamlFormSubmissionDevelGenerate::generateSubmissions in YAML Form 8

Generates submissions for a list of given forms.

Parameters

array $values: The element values from the settings form.

1 call to YamlFormSubmissionDevelGenerate::generateSubmissions()
YamlFormSubmissionDevelGenerate::generateElements in src/Plugin/DevelGenerate/YamlFormSubmissionDevelGenerate.php

File

src/Plugin/DevelGenerate/YamlFormSubmissionDevelGenerate.php, line 196

Class

YamlFormSubmissionDevelGenerate
Provides a YamlFormSubmissionDevelGenerate plugin.

Namespace

Drupal\yamlform\Plugin\DevelGenerate

Code

protected function generateSubmissions(array $values) {
  self::$generatingSubmissions = TRUE;
  if ($values['kill']) {
    $this
      ->deleteYamlFormSubmissions($values['yamlform_ids'], $values['entity-type'], $values['entity-id']);
    $this
      ->setMessage($this
      ->t('Deleted existing submissions.'));
  }
  if (!empty($values['yamlform_ids'])) {
    $this
      ->initializeGenerate($values);
    $start = time();
    for ($i = 1; $i <= $values['num']; $i++) {
      $this
        ->generateSubmission($values);
      if (function_exists('drush_log') && $i % drush_get_option('feedback', 1000) == 0) {
        $now = time();
        drush_log(dt('Completed @feedback submissions (@rate submissions/min)', [
          '@feedback' => drush_get_option('feedback', 1000),
          '@rate' => drush_get_option('feedback', 1000) * 60 / ($now - $start),
        ]), 'ok');
        $start = $now;
      }
    }
  }
  $this
    ->setMessage($this
    ->formatPlural($values['num'], '1 submissions created.', 'Finished creating @count submissions'));
  self::$generatingSubmissions = FALSE;
}