You are here

function config_import_drush_command in Config Importer and Tools 8.0

Same name and namespace in other branches
  1. 8.2 config_import.drush.inc \config_import_drush_command()
  2. 8 config_import.drush.inc \config_import_drush_command()

Implements hook_drush_command().

File

./config_import.drush.inc, line 15
Drush integration.

Code

function config_import_drush_command() {

  /* @var Command[] $commands */
  $commands = [];

  // Cannot continue without loaded container.
  if (!Drupal::hasContainer()) {
    return $commands;
  }
  $commands['config-import-types'] = new Command('conftypes', [
    'description' => dt('Output a list of available configuration types.'),
    'examples' => [
      '' => dt('Show all available configuration types.'),
    ],
  ]);
  $commands['config-import-names'] = new Command('confnames', [
    'description' => dt('Output a list of available configurations for a specific type.'),
    'options' => [
      'type' => TRUE,
    ],
    'examples' => [
      '--type=menu' => dt('Show all available configurations for specific type.'),
    ],
  ]);
  $commands['config-import-export'] = new Command('confexport', [
    'description' => dt('Output a configuration on the screen or into the file.'),
    'options' => [
      'type' => TRUE,
      'name' => TRUE,
      'destination' => FALSE,
    ],
    'examples' => [
      '--type=field_config --name=user.user.field_first_name' => dt('Output config on the screen. You can use output redirection operator to save contents into custom file.'),
      '--type=entity_browser --name=browse_files > example-config.yml' => dt('Save configuration into a custom file using output redirection operator.'),
      '--type=editor --name=full_html --destination=sites/default/config/staging' => dt('Save configuration into the file using fully qualified path to directory.'),
      '--type=menu --name=main --destination=staging' => dt('Save configuration into the file using the name of directory with configurations.'),
    ],
  ]);
  $commands['config-import-import'] = new Command('confimport', [
    'description' => dt('Import configuration from a file.'),
    'options' => [
      'type' => TRUE,
      'name' => TRUE,
      'destination' => TRUE,
    ],
    'examples' => [
      '--type=editor --destination=sites/default/config/staging' => dt('Import all configurations of specified type using fully qualified path to directory.'),
      '--type=menu --name=main --destination=staging' => dt('Import specific configuration from the file using the name of directory with configurations.'),
    ],
  ]);
  foreach ($commands as $command => $instance) {
    $commands[$command] = $instance
      ->getDefinition();
  }
  return $commands;
}