You are here

protected function DbImportCommand::execute in Drupal 9

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

File

core/lib/Drupal/Core/Command/DbImportCommand.php, line 35

Class

DbImportCommand
Provides a command to import the current database from a script.

Namespace

Drupal\Core\Command

Code

protected function execute(InputInterface $input, OutputInterface $output) {
  $script = $input
    ->getArgument('script');
  if (!is_file($script)) {
    $output
      ->writeln('File must exist.');
    return 1;
  }
  $connection = $this
    ->getDatabaseConnection($input);
  $this
    ->runScript($connection, $script);
  $output
    ->writeln('Import completed successfully.');
  return 0;
}