You are here

public function WebformCliService::webform_drush_command in Webform 6.x

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

Implements hook_drush_command().

Overrides WebformCliServiceInterface::webform_drush_command

2 calls to WebformCliService::webform_drush_command()
WebformCliService::drush_webform_generate_commands_drush8 in src/Commands/WebformCliService.php
Generate webform.drush.inc for Drush 8.x.
WebformCliService::drush_webform_generate_commands_drush9 in src/Commands/WebformCliService.php
Generate WebformCommands class for Drush 9.x.

File

src/Commands/WebformCliService.php, line 86

Class

WebformCliService
Drush version agnostic commands.

Namespace

Drupal\webform\Commands

Code

public function webform_drush_command() {
  $items = [];

  /* Submissions */
  $items['webform-export'] = [
    'description' => 'Exports webform submissions to a file.',
    'core' => [
      '8+',
    ],
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_SITE,
    'arguments' => [
      'webform' => 'The webform ID you want to export (required unless --entity-type and --entity-id are specified)',
    ],
    'options' => [
      'exporter' => 'The type of export. (delimited, table, yaml, or json)',
      // Delimited export options.
      'delimiter' => 'Delimiter between columns (defaults to site-wide setting). This option may need to be wrapped in quotes. i.e. --delimiter="\\t".',
      'multiple-delimiter' => 'Delimiter between an element with multiple values (defaults to site-wide setting).',
      // Document and managed file export options.
      'file-name' => 'File name used to export submission and uploaded filed. You may use tokens.',
      'archive-type' => 'Archive file type for submission file uploadeds and generated records. (tar or zip)',
      // Tabular export options.
      'header-format' => 'Set to "label" (default) or "key"',
      'options-item-format' => 'Set to "label" (default) or "key". Set to "key" to print select list values by their keys instead of labels.',
      'options-single-format' => 'Set to "separate" (default) or "compact" to determine how single select list values are exported.',
      'options-multiple-format' => 'Set to "separate" (default) or "compact" to determine how multiple select list values are exported.',
      'entity-reference-items' => 'Comma-separated list of entity reference items (id, title, and/or url) to be exported.',
      'excluded-columns' => 'Comma-separated list of component IDs or webform keys to exclude.',
      // CSV options
      'uuid' => ' Use UUIDs for all entity references. (Only applies to CSV download)',
      // Download options.
      'entity-type' => 'The entity type to which this submission was submitted from.',
      'entity-id' => 'The ID of the entity of which this webform submission was submitted from.',
      'range-type' => 'Range of submissions to export: "all", "latest", "serial", "sid", or "date".',
      'range-latest' => 'Integer specifying the latest X submissions will be downloaded. Used if "range-type" is "latest" or no other range options are provided.',
      'range-start' => 'The submission ID or start date at which to start exporting.',
      'range-end' => 'The submission ID or end date at which to end exporting.',
      'uid' => 'The ID of the user who submitted the form.',
      'order' => 'The submission order "asc" (default) or "desc".',
      'state' => 'Submission state to be included: "completed", "draft" or "all" (default).',
      'sticky' => 'Flagged/starred submission status.',
      'files' => 'Download files: "1" or "0" (default). If set to 1, the exported CSV file and any submission file uploads will be download in a gzipped tar file.',
      'attachments' => 'Download attachments: "1" or "0" (default). If set to 1, the exported CSV file and any submission element attachments will be download in a gzipped tar file.',
      // Output options.
      'destination' => 'The full path and filename in which the CSV or archive should be stored. If omitted the CSV file or archive will be outputted to the command line.',
    ],
    'aliases' => [
      'wfx',
    ],
  ];
  $items['webform-import'] = [
    'description' => 'Imports webform submissions from a CSV file.',
    'core' => [
      '8+',
    ],
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_SITE,
    'arguments' => [
      'webform' => 'The webform ID you want to import (required unless --entity-type and --entity-id are specified)',
      'import_uri' => 'The path or URI for the CSV file to be imported.',
    ],
    'options' => [
      // Import options.
      'skip_validation' => 'Skip form validation.',
      'treat_warnings_as_errors' => 'Treat all warnings as errors.',
      // Source entity options.
      'entity-type' => 'The entity type to which this submission was submitted from.',
      'entity-id' => 'The ID of the entity of which this webform submission was submitted from.',
    ],
    'aliases' => [
      'wfi',
    ],
  ];
  $items['webform-purge'] = [
    'description' => "Purge webform submissions from the databases",
    'core' => [
      '8+',
    ],
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_SITE,
    'arguments' => [
      'webform_id' => "A webform machine name. If not provided, user may choose from a list of names.",
    ],
    'options' => [
      'all' => '[boolean] Flush all submissions',
      'entity-type' => 'The entity type for webform submissions to be purged',
      'entity-id' => 'The ID of the entity for webform submissions to be purged',
    ],
    'examples' => [
      'drush webform-purge' => 'Pick a webform and then purge its submissions.',
      'drush webform-purge contact' => "Delete 'Contact' webform submissions.",
      'drush webform-purge --all' => 'Purge all webform submissions.',
    ],
    'aliases' => [
      'wfp',
    ],
  ];

  /* Tidy */
  $items['webform-tidy'] = [
    'description' => "Tidy export webform configuration files",
    'core' => [
      '8+',
    ],
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT,
    'options' => [
      'dependencies' => '[boolean] Add module dependencies to installed webform and options configuration entities.',
      'prefix' => 'Prefix for file names to be tidied. (Defaults to webform)',
    ],
    'arguments' => [
      'target' => "The module (config/install), config directory (sync), or path (/some/path) that needs its YAML configuration files tidied. (Defaults to webform)",
    ],
    'examples' => [
      'drush webform-tidy webform' => "Tidies YAML configuration files in 'webform/config' for the Webform module",
    ],
    'aliases' => [
      'wft',
    ],
  ];

  /* Libraries */
  $items['webform-libraries-status'] = [
    'description' => 'Displays the status of third party libraries required by the Webform module.',
    'core' => [
      '8+',
    ],
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT,
    'examples' => [
      'webform-libraries-status' => 'Displays the status of third party libraries required by the Webform module.',
    ],
    'aliases' => [
      'wfls',
    ],
  ];
  $items['webform-libraries-composer'] = [
    'description' => "Generates the Webform module's composer.json with libraries as repositories.",
    'core' => [
      '8+',
    ],
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT,
    'options' => [
      'disable-tls' => '[boolean] If set to true all HTTPS URLs will be tried with HTTP instead and no network level encryption is performed.',
    ],
    'examples' => [
      'webform-libraries-composer' => "Generates the Webform module's composer.json with libraries as repositories.",
    ],
    'aliases' => [
      'wflc',
    ],
  ];
  $items['webform-libraries-download'] = [
    'description' => 'Download third party libraries required by the Webform module.',
    'core' => [
      '8+',
    ],
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT,
    'examples' => [
      'webform-libraries-download' => 'Download third party libraries required by the Webform module.',
    ],
    'aliases' => [
      'wfld',
    ],
  ];
  $items['webform-libraries-remove'] = [
    'description' => 'Removes all downloaded third party libraries required by the Webform module.',
    'core' => [
      '8+',
    ],
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT,
    'examples' => [
      'webform-libraries-remove' => 'Removes all downloaded third party libraries required by the Webform module.',
    ],
    'aliases' => [
      'wflr',
    ],
  ];

  /* Devel Generate */
  $items['webform-generate'] = [
    'description' => 'Create submissions in specified webform.',
    'arguments' => [
      'webform_id' => 'Webform id into which new submissions will be inserted.',
      'num' => 'Number of submissions to insert. Defaults to 50.',
    ],
    'options' => [
      'kill' => '[boolean] Delete all submissions in specified webform before generating.',
      'feedback' => 'An integer representing interval for insertion rate logging. Defaults to 1000',
      'entity-type' => 'The entity type to which this submission was submitted from.',
      'entity-id' => 'The ID of the entity of which this webform submission was submitted from.',
    ],
    'aliases' => [
      'wfg',
    ],
  ];

  /* Repair */
  $items['webform-repair'] = [
    'description' => 'Makes sure all Webform admin configuration and webform settings are up-to-date.',
    'core' => [
      '8+',
    ],
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT,
    'examples' => [
      'webform-repair' => 'Repairs admin configuration and webform settings are up-to-date.',
    ],
    'aliases' => [
      'wfr',
    ],
  ];
  $items['webform-remove-orphans'] = [
    'description' => "Removes orphaned submissions where the submission's webform was deleted.",
    'core' => [
      '8+',
    ],
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT,
    'examples' => [
      'webform-remove-orphans' => "Removes orphaned submissions where the submission's webform was deleted.",
    ],
    'aliases' => [
      'wfro',
    ],
  ];

  /* Docs */
  $items['webform-docs'] = [
    'description' => 'Generates HTML documentation.',
    'core' => [
      '8+',
    ],
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT,
    'examples' => [
      'webform-docs' => 'Generates HTML documentation used by the Webform module\'s documentation pages.',
    ],
    'aliases' => [
      'wfd',
    ],
  ];

  /* Composer */
  $items['webform-composer-update'] = [
    'description' => "Updates the Drupal installation's composer.json to include the Webform module's selected libraries as repositories.",
    'core' => [
      '8+',
    ],
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT,
    'options' => [
      'disable-tls' => '[boolean] If set to true all HTTPS URLs will be tried with HTTP instead and no network level encryption is performed.',
    ],
    'examples' => [
      'webform-composer-update' => "Updates the Drupal installation's composer.json to include the Webform module's selected libraries as repositories.",
    ],
    'aliases' => [
      'wfcu',
    ],
  ];

  /* Generate commands */
  $items['webform-generate-commands'] = [
    'description' => 'Generate Drush commands from webform.drush.inc for Drush 8.x to WebformCommands for Drush 9.x.',
    'core' => [
      '8+',
    ],
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_SITE,
    'examples' => [
      'drush webform-generate-commands' => "Generate Drush commands from webform.drush.inc for Drush 8.x to WebformCommands for Drush 9.x.",
    ],
    'aliases' => [
      'wfgc',
    ],
  ];
  return $items;
}