/**
  * {@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]));
     }
 }
Beispiel #5
0
 /**
  * @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 execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $siteName = $input->getArgument('name');
     $directory = $input->getArgument('directory');
     $fileSystem = new Filesystem();
     if (!$fileSystem->exists($directory)) {
         $io->error(sprintf($this->trans('commands.site.import.local.messages.error-missing'), $directory));
         return 1;
     }
     $environment = $input->getOption('environment') ?: 'local';
     $siteConfig = [$environment => ['root' => $this->appRoot, 'host' => 'local']];
     $yaml = new Yaml();
     $dump = $yaml::dump($siteConfig);
     $userPath = sprintf('%s/.console/sites', $this->configurationManager->getHomeDirectory());
     $configFile = sprintf('%s/%s.yml', $userPath, $siteName);
     try {
         $fileSystem->dumpFile($configFile, $dump);
     } catch (\Exception $e) {
         $io->error(sprintf($this->trans('commands.site.import.local.messages.error-writing'), $e->getMessage()));
         return 1;
     }
     $io->success(sprintf($this->trans('commands.site.import.local.messages.imported')));
 }
 /**
  * @param DrupalStyle $io
  * @param string      $sitesDirectory
  * @return array
  */
 private function siteList($sitesDirectory)
 {
     $finder = new Finder();
     $finder->in($sitesDirectory);
     $finder->name("*.yml");
     $tableRows = [];
     foreach ($finder as $site) {
         $siteName = $site->getBasename('.yml');
         $environments = $this->configurationManager->readSite($site->getRealPath());
         foreach ($environments as $env => $config) {
             $tableRows[] = [$siteName . '.' . $env, array_key_exists('host', $config) ? $config['host'] : 'local', array_key_exists('root', $config) ? $config['root'] : ''];
         }
     }
     return $tableRows;
 }
Beispiel #8
0
 protected function loadConfigurations($env)
 {
     $configFile = sprintf('%s/.console/site.mode.yml', $this->configurationManager->getHomeDirectory());
     if (!file_exists($configFile)) {
         $configFile = sprintf('%s/config/dist/site.mode.yml', $this->appRoot);
     }
     $siteModeConfiguration = Yaml::dump(file_get_contents($configFile));
     $configKeys = array_keys($siteModeConfiguration);
     $configurationSettings = [];
     foreach ($configKeys as $configKey) {
         $siteModeConfigurationItem = $siteModeConfiguration[$configKey];
         foreach ($siteModeConfigurationItem as $setting => $parameters) {
             foreach ($parameters as $parameter => $value) {
                 $configurationSettings[$configKey][$setting][$parameter] = $value[$env];
             }
         }
     }
     return $configurationSettings;
 }
 /**
  * {@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);
     }
 }
Beispiel #10
0
 public static function createFileCache(Reader $reader, ConfigurationManager $configurationManager)
 {
     return new FileCacheReader($reader, $configurationManager->getHomeDirectory() . '/.console/cache/annotations', false);
 }