You are here

protected function DbDumpCommand::execute in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Command/DbDumpCommand.php \Drupal\Core\Command\DbDumpCommand::execute()

File

core/lib/Drupal/Core/Command/DbDumpCommand.php, line 51

Class

DbDumpCommand
Provides a command to dump the current database to a script.

Namespace

Drupal\Core\Command

Code

protected function execute(InputInterface $input, OutputInterface $output) {
  $connection = $this
    ->getDatabaseConnection($input);

  // If not explicitly set, disable ANSI which will break generated php.
  if ($input
    ->hasParameterOption([
    '--ansi',
  ]) !== TRUE) {
    $output
      ->setDecorated(FALSE);
  }
  $schema_tables = $input
    ->getOption('schema-only');
  $schema_tables = explode(',', $schema_tables);
  $output
    ->writeln($this
    ->generateScript($connection, $schema_tables), OutputInterface::OUTPUT_RAW);
  return 0;
}