function DbImportCommand::execute

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Command/DbImportCommand.php \Drupal\Core\Command\DbImportCommand::execute()
  2. 8.9.x core/lib/Drupal/Core/Command/DbImportCommand.php \Drupal\Core\Command\DbImportCommand::execute()
  3. 10 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) : int {
    $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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.