You are here

public function WebformCliService::drush_webform_generate in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Commands/WebformCliService.php \Drupal\webform\Commands\WebformCliService::drush_webform_generate()

Implements drush_hook_COMMAND().

Overrides WebformCliServiceInterface::drush_webform_generate

File

src/Commands/WebformCliService.php, line 652

Class

WebformCliService
Drush version agnostic commands.

Namespace

Drupal\webform\Commands

Code

public function drush_webform_generate($webform_id = NULL, $num = NULL) {
  $values = [
    'webform_ids' => [
      $webform_id => $webform_id,
    ],
    'num' => $num ?: 50,
    'feedback' => $this
      ->drush_get_option('feedback') ?: 1000,
    'kill' => $this
      ->drush_get_option('kill'),
    'entity-type' => $this
      ->drush_get_option('entity-type'),
    'entity-id' => $this
      ->drush_get_option('entity-id'),
  ];

  /** @var \Drupal\webform\Plugin\DevelGenerate\WebformSubmissionDevelGenerate $instance */
  $instance = \Drupal::service('plugin.manager.develgenerate')
    ->createInstance('webform_submission', []);
  $instance
    ->generate($values);
}