protected function execute(InputInterface $input, OutputInterface $output)
{
$sb = '<fg=black;bg=green>';
$se = '</fg=black;bg=green>';
$translator = $this->getContainer()->get('translator');
/** @var $dispatcher EventDispatcherInterface */
$dispatcher = $this->getContainer()->get('event_dispatcher');
/** @var HelperSet $helperSet */
$helperSet = $this->getHelperSet();
/** @var DialogHelper $dialog */
$dialog = $helperSet->get('dialog');
$kernel = $this->getContainer()->get('kernel');
$application = new Application($kernel);
$application->setAutoExit(false);
//$translator->setLocale('tr_TR');
$output->writeln($this->printWelcome());
$output->writeln('<info>' . $translator->trans('ojs.install.title') . '</info>');
if (!$input->getOption('no-interaction')) {
if (!$dialog->askConfirmation($output, '<question>' . $translator->trans('ojs.install.confirm') . ' (y/n) : </question>', true)) {
return;
}
}
if ($input->getOption('no-interaction')) {
$command1 = 'doctrine:schema:create';
$output->writeln('<info>Creating db schema!</info>');
$application->run(new StringInput($command1));
}
$command2 = 'doctrine:schema:update --force';
$output->writeln('<info>Updating db schema!</info>');
$application->run(new StringInput($command2));
if (!$input->getOption('no-location')) {
try {
$connection = $this->getContainer()->get('doctrine')->getConnection();
$connectionParams = $connection->getParams();
$location = $this->getContainer()->get('kernel')->getRootDir() . '/../vendor/bulutyazilim/location-bundle/Resources/data/location.sql';
$locationSql = file_get_contents($location);
$driver = $connectionParams['driver'];
if ($driver == 'pdo_mysql') {
$locationSql = 'SET foreign_key_checks = 0;' . $locationSql . 'SET foreign_key_checks = 1;';
} elseif ($driver == 'pdo_sqlite') {
$locationSql = 'PRAGMA foreign_keys = OFF;' . $locationSql . 'PRAGMA foreign_keys = ON;';
}
$connection->exec($locationSql);
$output->writeln('Locations inserted.');
} catch (\Exception $e) {
$output->writeln('Location insertion failed. --> ' . $e->getMessage());
}
}
if (!$input->getOption('no-role')) {
$output->writeln($sb . 'Inserting roles to db' . $se);
$this->insertRoles($output);
if (!$input->getOption('no-interaction')) {
if (!$input->getOption('no-admin')) {
$admin_username = $dialog->ask($output, '<info>Set system admin username (admin) : </info>', 'admin');
$admin_email = $dialog->ask($output, '<info>Set system admin email' . ' ([email protected]) : </info>', '[email protected]');
$admin_password = $dialog->ask($output, '<info>Set system admin password (admin) </info>', 'admin');
$output->writeln($sb . 'Inserting system admin user to db' . $se);
$this->insertAdmin($admin_username, $admin_email, $admin_password);
}
} else {
$output->writeln($sb . 'Inserting system admin user to db' . $se);
$this->insertAdmin('admin', 'admin@localhost', 'admin');
}
}
if (!$input->getOption('no-acl')) {
$output->writeln($sb . 'Inserting default ACL records' . $se);
$this->insertAcls();
}
if ($input->getOption('fix-acl')) {
$output->writeln($sb . 'Fixing ACL Records' . $se);
$this->fixAcls($output);
}
if (!$input->getOption('no-page')) {
$output->writeln($sb . 'Creating default pages' . $se);
$this->createDefaultPages();
}
$output->writeln("\nDONE\n");
$output->writeln("You can run" . " <info>php app/console ojs:install:samples</info> " . "to add some sample data.\n");
$event = new CoreEvent();
$dispatcher->dispatch(CoreEvents::OJS_INSTALL_BASE, $event);
}