protected function execute(InputInterface $input, OutputInterface $output)
{
$this->iohandler_factory->set_environment('cli');
/** @var \phpbb\install\helper\iohandler\cli_iohandler $iohandler */
$iohandler = $this->iohandler_factory->get();
$style = new SymfonyStyle($input, $output);
$iohandler->set_style($style, $output);
$this->installer->set_iohandler($iohandler);
$config_file = $input->getArgument('config-file');
if ($this->install_helper->is_phpbb_installed()) {
$iohandler->add_error_message('INSTALL_PHPBB_INSTALLED');
return 1;
}
if (!is_file($config_file)) {
$iohandler->add_error_message(array('MISSING_FILE', $config_file));
return 1;
}
try {
$config = Yaml::parse(file_get_contents($config_file), true, false);
} catch (ParseException $e) {
$iohandler->add_error_message(array('INVALID_YAML_FILE', $config_file));
return 1;
}
$processor = new Processor();
$configuration = new installer_configuration();
try {
$config = $processor->processConfiguration($configuration, $config);
} catch (Exception $e) {
$iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage());
return 1;
}
$this->register_configuration($iohandler, $config);
try {
$this->installer->run();
return 0;
} catch (installer_exception $e) {
$iohandler->add_error_message($e->getMessage());
return 1;
}
}