X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FSite%2FInstallCommand.php;fp=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FSite%2FInstallCommand.php;h=0a5254079e574459ac6b1c67e9c2f3707296bf71;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hp=720fd57d9a9067a97a7eda16d0209153b86bb1cd;hpb=aea91e65e895364e460983b890e295aa5d5540a5;p=yaffs-website diff --git a/vendor/drupal/console/src/Command/Site/InstallCommand.php b/vendor/drupal/console/src/Command/Site/InstallCommand.php index 720fd57d9..0a5254079 100644 --- a/vendor/drupal/console/src/Command/Site/InstallCommand.php +++ b/vendor/drupal/console/src/Command/Site/InstallCommand.php @@ -9,26 +9,22 @@ namespace Drupal\Console\Command\Site; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Config\Definition\Exception\Exception; -use Symfony\Component\Console\Input\ArgvInput; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Command\Command; +use Drupal\Console\Core\Command\ContainerAwareCommand; use Drupal\Core\Database\Database; use Drupal\Core\Installer\Exception\AlreadyInstalledException; -use Drupal\Console\Core\Command\Shared\ContainerAwareCommandTrait; use Drupal\Console\Command\Shared\DatabaseTrait; use Drupal\Console\Core\Utils\ConfigurationManager; use Drupal\Console\Extension\Manager; -use Drupal\Console\Core\Style\DrupalStyle; use Drupal\Console\Bootstrap\Drupal; use Drupal\Console\Utils\Site; -use DrupalFinder\DrupalFinder; +use Drupal\Console\Core\Utils\DrupalFinder; -class InstallCommand extends Command +class InstallCommand extends ContainerAwareCommand { - use ContainerAwareCommandTrait; use DatabaseTrait; /** @@ -86,19 +82,19 @@ class InstallCommand extends Command 'langcode', null, InputOption::VALUE_REQUIRED, - $this->trans('commands.site.install.options.langcode') + $this->trans('commands.site.install.arguments.langcode') ) ->addOption( 'db-type', null, InputOption::VALUE_REQUIRED, - $this->trans('commands.site.install.options.db-type') + $this->trans('commands.site.install.arguments.db-type') ) ->addOption( 'db-file', null, InputOption::VALUE_REQUIRED, - $this->trans('commands.site.install.options.db-file') + $this->trans('commands.site.install.arguments.db-file') ) ->addOption( 'db-host', @@ -140,38 +136,39 @@ class InstallCommand extends Command 'site-name', null, InputOption::VALUE_REQUIRED, - $this->trans('commands.site.install.options.site-name') + $this->trans('commands.site.install.arguments.site-name') ) ->addOption( 'site-mail', null, InputOption::VALUE_REQUIRED, - $this->trans('commands.site.install.options.site-mail') + $this->trans('commands.site.install.arguments.site-mail') ) ->addOption( 'account-name', null, InputOption::VALUE_REQUIRED, - $this->trans('commands.site.install.options.account-name') + $this->trans('commands.site.install.arguments.account-name') ) ->addOption( 'account-mail', null, InputOption::VALUE_REQUIRED, - $this->trans('commands.site.install.options.account-mail') + $this->trans('commands.site.install.arguments.account-mail') ) ->addOption( 'account-pass', null, InputOption::VALUE_REQUIRED, - $this->trans('commands.site.install.options.account-pass') + $this->trans('commands.site.install.arguments.account-pass') ) ->addOption( 'force', null, InputOption::VALUE_NONE, - $this->trans('commands.site.install.options.force') - ); + $this->trans('commands.site.install.arguments.force') + ) + ->setAliases(['si']); } /** @@ -179,8 +176,6 @@ class InstallCommand extends Command */ protected function interact(InputInterface $input, OutputInterface $output) { - $io = new DrupalStyle($input, $output); - // --profile option $profile = $input->getArgument('profile'); if (!$profile) { @@ -199,7 +194,7 @@ class InstallCommand extends Command } ); - $profile = $io->choice( + $profile = $this->getIo()->choice( $this->trans('commands.site.install.questions.profile'), array_values($profiles) ); @@ -215,7 +210,7 @@ class InstallCommand extends Command ->getConfiguration() ->get('application.language'); - $langcode = $io->choiceNoList( + $langcode = $this->getIo()->choiceNoList( $this->trans('commands.site.install.questions.langcode'), $languages, $languages[$defaultLanguage] @@ -231,7 +226,7 @@ class InstallCommand extends Command $dbType = $input->getOption('db-type'); if (!$dbType) { $databases = $this->site->getDatabaseTypes(); - $dbType = $io->choice( + $dbType = $this->getIo()->choice( $this->trans('commands.migrate.setup.questions.db-type'), array_column($databases, 'name') ); @@ -249,7 +244,7 @@ class InstallCommand extends Command // --db-file option $dbFile = $input->getOption('db-file'); if (!$dbFile) { - $dbFile = $io->ask( + $dbFile = $this->getIo()->ask( $this->trans('commands.migrate.execute.questions.db-file'), 'sites/default/files/.ht.sqlite' ); @@ -259,35 +254,35 @@ class InstallCommand extends Command // --db-host option $dbHost = $input->getOption('db-host'); if (!$dbHost) { - $dbHost = $this->dbHostQuestion($io); + $dbHost = $this->dbHostQuestion(); $input->setOption('db-host', $dbHost); } // --db-name option $dbName = $input->getOption('db-name'); if (!$dbName) { - $dbName = $this->dbNameQuestion($io); + $dbName = $this->dbNameQuestion(); $input->setOption('db-name', $dbName); } // --db-user option $dbUser = $input->getOption('db-user'); if (!$dbUser) { - $dbUser = $this->dbUserQuestion($io); + $dbUser = $this->dbUserQuestion(); $input->setOption('db-user', $dbUser); } // --db-pass option $dbPass = $input->getOption('db-pass'); if (!$dbPass) { - $dbPass = $this->dbPassQuestion($io); + $dbPass = $this->dbPassQuestion(); $input->setOption('db-pass', $dbPass); } // --db-port prefix $dbPort = $input->getOption('db-port'); if (!$dbPort) { - $dbPort = $this->dbPortQuestion($io); + $dbPort = $this->dbPortQuestion(); $input->setOption('db-port', $dbPort); } } @@ -295,7 +290,7 @@ class InstallCommand extends Command // --db-prefix $dbPrefix = $input->getOption('db-prefix'); if (!$dbPrefix) { - $dbPrefix = $this->dbPrefixQuestion($io); + $dbPrefix = $this->dbPrefixQuestion(); $input->setOption('db-prefix', $dbPrefix); } } else { @@ -306,7 +301,7 @@ class InstallCommand extends Command $input->setOption('db-pass', $database['default']['password']); $input->setOption('db-port', $database['default']['port']); $input->setOption('db-prefix', $database['default']['prefix']['default']); - $io->info( + $this->getIo()->info( sprintf( $this->trans('commands.site.install.messages.using-current-database'), $database['default']['driver'], @@ -319,9 +314,9 @@ class InstallCommand extends Command // --site-name option $siteName = $input->getOption('site-name'); if (!$siteName) { - $siteName = $io->ask( + $siteName = $this->getIo()->ask( $this->trans('commands.site.install.questions.site-name'), - 'Drupal 8' + $this->trans('commands.site.install.suggestions.site-name') ); $input->setOption('site-name', $siteName); } @@ -329,7 +324,7 @@ class InstallCommand extends Command // --site-mail option $siteMail = $input->getOption('site-mail'); if (!$siteMail) { - $siteMail = $io->ask( + $siteMail = $this->getIo()->ask( $this->trans('commands.site.install.questions.site-mail'), 'admin@example.com' ); @@ -339,7 +334,7 @@ class InstallCommand extends Command // --account-name option $accountName = $input->getOption('account-name'); if (!$accountName) { - $accountName = $io->ask( + $accountName = $this->getIo()->ask( $this->trans('commands.site.install.questions.account-name'), 'admin' ); @@ -349,7 +344,7 @@ class InstallCommand extends Command // --account-pass option $accountPass = $input->getOption('account-pass'); if (!$accountPass) { - $accountPass = $io->askHidden( + $accountPass = $this->getIo()->askHidden( $this->trans('commands.site.install.questions.account-pass') ); $input->setOption('account-pass', $accountPass); @@ -358,7 +353,7 @@ class InstallCommand extends Command // --account-mail option $accountMail = $input->getOption('account-mail'); if (!$accountMail) { - $accountMail = $io->ask( + $accountMail = $this->getIo()->ask( $this->trans('commands.site.install.questions.account-mail'), $siteMail ); @@ -371,12 +366,11 @@ class InstallCommand extends Command */ protected function execute(InputInterface $input, OutputInterface $output) { - $io = new DrupalStyle($input, $output); - $uri = parse_url($input->getParameterOption(['--uri', '-l'], 'default'), PHP_URL_HOST); + $uri = parse_url($input->getParameterOption(['--uri', '-l'], 'default'), PHP_URL_HOST); if ($this->site->multisiteMode($uri)) { if (!$this->site->validMultisite($uri)) { - $io->error( + $this->getIo()->error( sprintf($this->trans('commands.site.install.messages.invalid-multisite'), $uri, $uri) ); exit(1); @@ -424,7 +418,7 @@ class InstallCommand extends Command 'driver' => $dbType, ]; - if ($force && Database::getConnectionInfo()) { + if ($force && Database::isActiveConnection()) { $schema = Database::getConnection()->schema(); $tables = $schema->findTables('%'); foreach ($tables as $table) { @@ -436,21 +430,24 @@ class InstallCommand extends Command try { $drupalFinder = new DrupalFinder(); $drupalFinder->locateRoot(getcwd()); - $composerRoot = $drupalFinder->getComposerRoot(); - $drupalRoot = $drupalFinder->getDrupalRoot(); - - $this->runInstaller($io, $input, $database, $uri); + $this->runInstaller($database, $uri); $autoload = $this->container->get('class_loader'); - $drupal = new Drupal($autoload, $composerRoot, $drupalRoot); + $drupal = new Drupal( + $autoload, + $drupalFinder, + $this->configurationManager + ); $container = $drupal->boot(); $this->getApplication()->setContainer($container); + $this->getApplication()->validateCommands(); + $this->getApplication()->loadCommands(); } catch (Exception $e) { - $io->error($e->getMessage()); + $this->getIo()->error($e->getMessage()); return 1; } - $this->restoreSitesFile($io); + $this->restoreSitesFile(); return 0; } @@ -462,11 +459,9 @@ class InstallCommand extends Command * install files to be placed directly under /sites instead of the * appropriate subdir when run from a script and a sites.php file exists. * - * @param DrupalStyle $output - * * @return boolean */ - protected function backupSitesFile(DrupalStyle $output) + protected function backupSitesFile() { if (!file_exists($this->appRoot . '/sites/sites.php')) { return true; @@ -474,7 +469,7 @@ class InstallCommand extends Command $renamed = rename($this->appRoot . '/sites/sites.php', $this->appRoot . '/sites/backup.sites.php'); - $output->info($this->trans('commands.site.install.messages.sites-backup')); + $this->getIo()->info($this->trans('commands.site.install.messages.sites-backup')); return $renamed; } @@ -482,11 +477,9 @@ class InstallCommand extends Command /** * Restores backup.sites.php to sites.php (if needed). * - * @param DrupalStyle $output - * * @return boolean */ - protected function restoreSitesFile(DrupalStyle $output) + protected function restoreSitesFile() { if (!file_exists($this->appRoot . '/sites/backup.sites.php')) { return true; @@ -494,17 +487,13 @@ class InstallCommand extends Command $renamed = rename($this->appRoot . '/sites/backup.sites.php', $this->appRoot . '/sites/sites.php'); - $output->info($this->trans('commands.site.install.messages.sites-restore')); + $this->getIo()->info($this->trans('commands.site.install.messages.sites-restore')); return $renamed; } - protected function runInstaller( - DrupalStyle $io, - InputInterface $input, - $database, - $uri - ) { + protected function runInstaller($database, $uri) { + $input = $this->getIo()->getInput(); $this->site->loadLegacyFile('/core/includes/install.core.inc'); $driver = (string)$database['driver']; @@ -542,28 +531,28 @@ class InstallCommand extends Command ]; if (!$this->site->multisiteMode($uri)) { - $this->backupSitesFile($io); + $this->backupSitesFile(); } - $io->newLine(); - $io->info($this->trans('commands.site.install.messages.installing')); + $this->getIo()->newLine(); + $this->getIo()->info($this->trans('commands.site.install.messages.installing')); try { $autoload = $this->site->getAutoload(); install_drupal($autoload, $settings); } catch (AlreadyInstalledException $e) { - $io->error($this->trans('commands.site.install.messages.already-installed')); + $this->getIo()->error($this->trans('commands.site.install.messages.already-installed')); return 1; } catch (\Exception $e) { - $io->error($e->getMessage()); + $this->getIo()->error($e->getMessage()); return 1; } if (!$this->site->multisiteMode($uri)) { - $this->restoreSitesFile($io); + $this->restoreSitesFile(); } - $io->success($this->trans('commands.site.install.messages.installed')); + $this->getIo()->success($this->trans('commands.site.install.messages.installed')); return 0; }