/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $language = $input->getArgument('language'); $format = $input->getOption('format'); $languages = $this->configurationManager->getConfiguration()->get('application.languages'); unset($languages['en']); if ($language && !isset($languages[$language])) { $io->error(sprintf($this->trans('commands.translation.stats.messages.invalid-language'), $language)); return 1; } if ($language) { $languages = [$language => $languages[$language]]; } $stats = $this->calculateStats($io, $language, $languages); if ($format == 'table') { $tableHeaders = [$this->trans('commands.translation.stats.messages.language'), $this->trans('commands.translation.stats.messages.percentage'), $this->trans('commands.translation.stats.messages.iso')]; $io->table($tableHeaders, $stats); return 0; } if ($format == 'markdown') { $arguments['language'] = $this->trans('commands.translation.stats.messages.language'); $arguments['percentage'] = $this->trans('commands.translation.stats.messages.percentage'); $arguments['languages'] = $stats; $io->writeln($this->renderFile('core/translation/stats.md.twig', null, $arguments)); } }
protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $this->site->loadLegacyFile('/core/modules/system/system.module'); $status = strtolower($input->getOption('status')); $type = strtolower($input->getOption('type')); $modules = strtolower($input->getArgument('module')); if ($modules) { $config = $this->configurationManager->getConfiguration(); $repo = $config->get('application.composer.repositories.default'); foreach ($modules as $module) { $url = sprintf('%s/packages/drupal/%s.json', $config->get('application.composer.packages.default'), $module); try { $data = $this->httpClient->getUrlAsJson($repo . $url); } catch (\Exception $e) { $io->error(sprintf($this->trans('commands.module.debug.messages.no-results'), $module)); return 1; } $tableHeader = ['<info>' . $data->package->name . '</info>']; $tableRows = []; $tableRows[] = [$data->package->description]; $tableRows[] = ['<comment>' . $this->trans('commands.module.debug.messages.total-downloads') . '</comment>', $data->package->downloads->total]; $tableRows[] = ['<comment>' . $this->trans('commands.module.debug.messages.total-monthly') . '</comment>', $data->package->downloads->monthly]; $tableRows[] = ['<comment>' . $this->trans('commands.module.debug.messages.total-daily') . '</comment>', $data->package->downloads->daily]; $io->table($tableHeader, $tableRows, 'compact'); } return 0; } if ($status == 'installed') { $status = 1; } elseif ($status == 'uninstalled') { $status = 0; } else { $status = -1; } if ($type == 'core') { $type = 'core'; } elseif ($type == 'no-core') { $type = ''; } else { $type = null; } $tableHeader = [$this->trans('commands.module.debug.messages.id'), $this->trans('commands.module.debug.messages.name'), $this->trans('commands.module.debug.messages.package'), $this->trans('commands.module.debug.messages.version'), $this->trans('commands.module.debug.messages.schema-version'), $this->trans('commands.module.debug.messages.status'), $this->trans('commands.module.debug.messages.origin')]; $tableRows = []; $modules = system_rebuild_module_data(); foreach ($modules as $module_id => $module) { if ($status >= 0 && $status != $module->status) { continue; } if ($type !== null && $type !== $module->origin) { continue; } $module_status = $module->status ? $this->trans('commands.module.debug.messages.installed') : $this->trans('commands.module.debug.messages.uninstalled'); $module_origin = $module->origin ? $module->origin : 'no core'; $schema_version = drupal_get_installed_schema_version($module_id) != -1 ? drupal_get_installed_schema_version($module_id) : ''; $tableRows[] = [$module_id, $module->info['name'], $module->info['package'], $module->info['version'], $schema_version, $module_status, $module_origin]; } $io->table($tableHeader, $tableRows, 'compact'); }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $language = $input->getArgument('language'); $languages = $this->configurationManager->getConfiguration()->get('application.languages'); unset($languages['en']); if ($language && !isset($languages[$language])) { $io->error(sprintf($this->trans('commands.translation.cleanup.messages.invalid-language'), $language)); return 1; } if ($language) { $languages = [$language => $languages[$language]]; } $this->cleanupTranslations($io, $language, $languages); $io->success($this->trans('commands.translation.cleanup.messages.success')); }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $language = $input->getArgument('language'); $file = $input->getOption('file'); $languages = $this->configurationManager->getConfiguration()->get('application.languages'); unset($languages['en']); if ($language && !isset($languages[$language])) { $io->error(sprintf($this->trans('commands.translation.pending.messages.invalid-language'), $language)); return 1; } if ($language) { $languages = [$language => $languages[$language]]; } $pendingTranslations = $this->determinePendingTranslation($io, $language, $languages, $file); if ($file) { $io->success(sprintf($this->trans('commands.translation.pending.messages.success-language-file'), $pendingTranslations, $languages[$language], $file)); } else { $io->success(sprintf($this->trans('commands.translation.pending.messages.success-language'), $pendingTranslations, $languages[$language])); } }
/** * @return string */ protected function getEditor() { $config = $this->configurationManager->getConfiguration(); $editor = $config->get('application.editor', 'vi'); if ($editor != '') { return trim($editor); } $processBuilder = new ProcessBuilder(array('bash')); $process = $processBuilder->getProcess(); $process->setCommandLine('echo ${EDITOR:-${VISUAL:-vi}}'); $process->run(); $editor = $process->getOutput(); $process->stop(); return trim($editor); }
/** * {@inheritdoc} */ protected function interact(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); // --profile option $profile = $input->getArgument('profile'); if (!$profile) { $profiles = $this->extensionManager->discoverProfiles()->showCore()->showNoCore()->showInstalled()->showUninstalled()->getList(true); $profiles = array_filter($profiles, function ($profile) { return strpos($profile, 'testing') !== 0; }); $profile = $io->choice($this->trans('commands.site.install.questions.profile'), $profiles); $input->setArgument('profile', $profile); } // // --langcode option $langcode = $input->getOption('langcode'); if (!$langcode) { $languages = $this->site->getStandardLanguages(); $defaultLanguage = $this->configurationManager->getConfiguration()->get('application.language'); $langcode = $io->choiceNoList($this->trans('commands.site.install.questions.langcode'), $languages, $languages[$defaultLanguage]); $input->setOption('langcode', $langcode); } // Use default database setting if is available $database = Database::getConnectionInfo(); if (empty($database['default'])) { // --db-type option $dbType = $input->getOption('db-type'); if (!$dbType) { $databases = $this->site->getDatabaseTypes(); $dbType = $io->choice($this->trans('commands.migrate.setup.questions.db-type'), array_column($databases, 'name')); foreach ($databases as $dbIndex => $database) { if ($database['name'] == $dbType) { $dbType = $dbIndex; } } $input->setOption('db-type', $dbType); } if ($dbType === 'sqlite') { // --db-file option $dbFile = $input->getOption('db-file'); if (!$dbFile) { $dbFile = $io->ask($this->trans('commands.migrate.execute.questions.db-file'), 'sites/default/files/.ht.sqlite'); $input->setOption('db-file', $dbFile); } } else { // --db-host option $dbHost = $input->getOption('db-host'); if (!$dbHost) { $dbHost = $this->dbHostQuestion($io); $input->setOption('db-host', $dbHost); } // --db-name option $dbName = $input->getOption('db-name'); if (!$dbName) { $dbName = $this->dbNameQuestion($io); $input->setOption('db-name', $dbName); } // --db-user option $dbUser = $input->getOption('db-user'); if (!$dbUser) { $dbUser = $this->dbUserQuestion($io); $input->setOption('db-user', $dbUser); } // --db-pass option $dbPass = $input->getOption('db-pass'); if (!$dbPass) { $dbPass = $this->dbPassQuestion($io); $input->setOption('db-pass', $dbPass); } // --db-port prefix $dbPort = $input->getOption('db-port'); if (!$dbPort) { $dbPort = $this->dbPortQuestion($io); $input->setOption('db-port', $dbPort); } } // --db-prefix $dbPrefix = $input->getOption('db-prefix'); if (!$dbPrefix) { $dbPrefix = $this->dbPrefixQuestion($io); $input->setOption('db-prefix', $dbPrefix); } } else { $input->setOption('db-type', $database['default']['driver']); $input->setOption('db-host', $database['default']['host']); $input->setOption('db-name', $database['default']['database']); $input->setOption('db-user', $database['default']['username']); $input->setOption('db-pass', $database['default']['password']); $input->setOption('db-port', $database['default']['port']); $input->setOption('db-prefix', $database['default']['prefix']['default']); $io->info(sprintf($this->trans('commands.site.install.messages.using-current-database'), $database['default']['driver'], $database['default']['database'], $database['default']['username'])); } // --site-name option $siteName = $input->getOption('site-name'); if (!$siteName) { $siteName = $io->ask($this->trans('commands.site.install.questions.site-name'), 'Drupal 8 Site Install'); $input->setOption('site-name', $siteName); } // --site-mail option $siteMail = $input->getOption('site-mail'); if (!$siteMail) { $siteMail = $io->ask($this->trans('commands.site.install.questions.site-mail'), '*****@*****.**'); $input->setOption('site-mail', $siteMail); } // --account-name option $accountName = $input->getOption('account-name'); if (!$accountName) { $accountName = $io->ask($this->trans('commands.site.install.questions.account-name'), 'admin'); $input->setOption('account-name', $accountName); } // --account-pass option $accountPass = $input->getOption('account-pass'); if (!$accountPass) { $accountPass = $io->askHidden($this->trans('commands.site.install.questions.account-pass')); $input->setOption('account-pass', $accountPass); } // --account-mail option $accountMail = $input->getOption('account-mail'); if (!$accountMail) { $accountMail = $io->ask($this->trans('commands.site.install.questions.account-mail'), $siteMail); $input->setOption('account-mail', $accountMail); } }