/**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     // --module option
     $module = $input->getOption('module');
     if (!$module) {
         // @see Drupal\Console\Command\Shared\ModuleTrait::moduleQuestion
         $module = $this->moduleQuestion($output);
         $input->setOption('module', $module);
     }
     // --name option
     $name = $input->getOption('name');
     if (!$name) {
         $name = $io->ask($this->trans('commands.generate.twig.extension.questions.twig-extension'), $module . '.twig.extension');
         $input->setOption('name', $name);
     }
     // --class option
     $class = $input->getOption('class');
     if (!$class) {
         $class = $io->ask($this->trans('commands.common.options.class'), 'DefaultTwigExtension');
         $input->setOption('class', $class);
     }
     // --services option
     $services = $input->getOption('services');
     if (!$services) {
         // @see Drupal\Console\Command\Shared\ServicesTrait::servicesQuestion
         $services = $this->servicesQuestion($output);
         $input->setOption('services', $services);
     }
 }
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     // --module option
     $module = $input->getOption('module');
     if (!$module) {
         // @see Drupal\Console\Command\ModuleTrait::moduleQuestion
         $module = $this->moduleQuestion($output);
         $input->setOption('module', $module);
     }
     // --class option
     $class = $input->getOption('class');
     if (!$class) {
         $class = $io->ask($this->trans('commands.generate.plugin.mail.options.class'), 'HtmlFormatterMail', function ($class) {
             return $this->validateClassName($class);
         });
         $input->setOption('class', $class);
     }
     // --label option
     $label = $input->getOption('label');
     if (!$label) {
         $label = $io->ask($this->trans('commands.generate.plugin.mail.options.label'), $this->getStringHelper()->camelCaseToHuman($class));
         $input->setOption('label', $label);
     }
     // --plugin-id option
     $pluginId = $input->getOption('plugin-id');
     if (!$pluginId) {
         $pluginId = $io->ask($this->trans('commands.generate.plugin.mail.options.plugin-id'), $this->getStringHelper()->camelCaseToUnderscore($class));
         $input->setOption('plugin-id', $pluginId);
     }
     // --services option
     // @see Drupal\Console\Command\ServicesTrait::servicesQuestion
     $services = $this->servicesQuestion($output);
     $input->setOption('services', $services);
 }
Exemple #3
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $tableHeader = [$this->trans('commands.queue.debug.messages.queue'), $this->trans('commands.queue.debug.messages.items'), $this->trans('commands.queue.debug.messages.class')];
     $tableBody = $this->listQueues();
     $io->table($tableHeader, $tableBody);
 }
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $validator_filename = function ($value) use($io) {
         if (!strlen(trim($value)) || !is_file($value)) {
             $io->error($this->trans('commands.common.errors.invalid-file-path'));
             return false;
         }
         return $value;
     };
     // --yaml-left option
     $yaml_left = $input->getArgument('yaml-left');
     if (!$yaml_left) {
         while (true) {
             $yaml_left = $output->ask($this->trans('commands.yaml.diff.questions.yaml-left'), null, $validator_filename);
             if ($yaml_left) {
                 break;
             }
         }
         $input->setArgument('yaml-left', $yaml_left);
     }
     // --yaml-right option
     $yaml_right = $input->getArgument('yaml-right');
     if (!$yaml_right) {
         while (true) {
             $yaml_right = $output->ask($this->trans('commands.yaml.diff.questions.yaml-right'), null, $validator_filename);
             if ($yaml_right) {
                 break;
             }
         }
         $input->setArgument('yaml-right', $yaml_right);
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $moduleHandler = $this->moduleHandler;
     $moduleHandler->loadInclude('locale', 'inc', 'locale.translation');
     $moduleHandler->loadInclude('locale', 'module');
     $language = $input->getArgument('language');
     $languagesObjects = locale_translatable_language_list();
     $languages = $this->site->getStandardLanguages();
     if (isset($languagesObjects[$language])) {
         $languageEntity = $languagesObjects[$language];
     } elseif (array_search($language, $languages)) {
         $langcode = array_search($language, $languages);
         $languageEntity = $languagesObjects[$langcode];
     } else {
         $io->error(sprintf($this->trans('commands.locale.language.delete.messages.invalid-language'), $language));
         return 1;
     }
     try {
         $configurable_language_storage = $this->entityTypeManager->getStorage('configurable_language');
         $configurable_language_storage->load($languageEntity->getId())->delete();
         $io->info(sprintf($this->trans('commands.locale.language.delete.messages.language-deleted-successfully'), $languageEntity->getName()));
     } catch (\Exception $e) {
         $io->error($e->getMessage());
         return 1;
     }
     return 0;
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $language = $input->getArgument('language');
     $tableHeader = [$this->trans('commands.locale.translation.status.messages.project'), $this->trans('commands.locale.translation.status.messages.version'), $this->trans('commands.locale.translation.status.messages.local-age'), $this->trans('commands.locale.translation.status.messages.remote-age'), $this->trans('commands.locale.translation.status.messages.info')];
     $languages = locale_translatable_language_list();
     $status = locale_translation_get_status();
     $this->getModuleHandler()->loadInclude('locale', 'compare.inc');
     if (!$languages) {
         $io->info($this->trans('commands.locale.translation.status.messages.no-languages'));
         return;
     } elseif (empty($status)) {
         $io->info($this->trans('commands.locale.translation.status.messages.no-translations'));
         return;
     }
     if ($languages) {
         $projectsStatus = $this->projectsStatus();
         foreach ($projectsStatus as $langcode => $rows) {
             $tableRows = [];
             if ($language != '' && !($language == $langcode || strtolower($language) == strtolower($languages[$langcode]->getName()))) {
                 continue;
             }
             $io->info($languages[$langcode]->getName());
             foreach ($rows as $row) {
                 if ($row[0] == 'drupal') {
                     $row[0] = $this->trans('commands.common.messages.drupal-core');
                 }
                 $tableRows[] = $row;
             }
             $io->table($tableHeader, $tableRows, 'compact');
         }
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $module_handler = $this->getModuleHandler();
     $io->section($this->trans('commands.cron.debug.messages.module-list'));
     $io->table([$this->trans('commands.cron.debug.messages.module')], $module_handler->getImplementations('cron'), 'compact');
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /**
      * DrupalConsole extends the SymfonyStyle class to provide
      * an standardized Output Formatting Style.
      *
      * Drupal Console provides the DrupalStyle helper class:
      */
     $io = new DrupalStyle($input, $output);
     $io->simple('This text could be translatable by');
     $io->simple('adding a YAML file at "config/translations/LANGUAGE/command.name.yml"');
     /**
      *  By using ContainerAwareCommand as the base class for the command
      *  (instead of the more basic Command), you have access to
      *  the service container.
      *
      *  In other words, you can access to any configured Drupal service
      *  using the provided getService method.
      *
      *  $this->getService('entity_type.manager');
      *
      *  Reading user input argument
      *  $input->getArgument('ARGUMENT_NAME');
      *
      *  Reading user input option
      *  $input->getOption('OPTION_NAME');
      */
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $resource_id = $input->getArgument('resource-id');
     $rest_resources = $this->getRestResources();
     $rest_resources_ids = array_merge(array_keys($rest_resources['enabled']), array_keys($rest_resources['disabled']));
     if (!$resource_id) {
         $resource_id = $io->choiceNoList($this->trans('commands.rest.enable.arguments.resource-id'), $rest_resources_ids);
     }
     $this->validateRestResource($resource_id, $rest_resources_ids, $this->translator);
     $input->setArgument('resource-id', $resource_id);
     // Calculate states available by resource and generate the question.
     $plugin = $this->pluginManagerRest->getInstance(['id' => $resource_id]);
     $methods = $plugin->availableMethods();
     $method = $io->choice($this->trans('commands.rest.enable.arguments.methods'), $methods);
     $io->writeln($this->trans('commands.rest.enable.messages.selected-method') . ' ' . $method);
     $format = $io->choice($this->trans('commands.rest.enable.arguments.formats'), $this->formats);
     $io->writeln($this->trans('commands.rest.enable.messages.selected-format') . ' ' . $format);
     // Get Authentication Provider and generate the question
     $authenticationProviders = $this->authenticationCollector->getSortedProviders();
     $authenticationProvidersSelected = $io->choice($this->trans('commands.rest.enable.messages.authentication-providers'), array_keys($authenticationProviders), 0, true);
     $io->writeln($this->trans('commands.rest.enable.messages.selected-authentication-providers') . ' ' . implode(', ', $authenticationProvidersSelected));
     $format_resource_id = str_replace(':', '.', $resource_id);
     $config = $this->entityManager->getStorage('rest_resource_config')->load($format_resource_id);
     if (!$config) {
         $config = $this->entityManager->getStorage('rest_resource_config')->create(['id' => $format_resource_id, 'granularity' => RestResourceConfigInterface::METHOD_GRANULARITY, 'configuration' => []]);
     }
     $configuration = $config->get('configuration') ?: [];
     $configuration[$method] = ['supported_formats' => [$format], 'supported_auth' => $authenticationProvidersSelected];
     $config->set('configuration', $configuration);
     $config->save();
     $message = sprintf($this->trans('commands.rest.enable.messages.success'), $resource_id);
     $io->info($message);
     return true;
 }
 /**
  * @param \Drupal\Console\Style\DrupalStyle $io
  * @param $eventType
  * @param $eventSeverity
  * @param $userId
  * @return bool
  */
 protected function clearEvents(DrupalStyle $io, $eventType, $eventSeverity, $userId)
 {
     $connection = $this->getDatabase();
     $severity = RfcLogLevel::getLevels();
     $query = $connection->delete('watchdog');
     if ($eventType) {
         $query->condition('type', $eventType);
     }
     if ($eventSeverity) {
         if (!in_array($eventSeverity, $severity)) {
             $io->error(sprintf($this->trans('commands.database.log.clear.messages.invalid-severity'), $eventSeverity));
             return false;
         }
         $query->condition('severity', array_search($eventSeverity, $severity));
     }
     if ($userId) {
         $query->condition('uid', $userId);
     }
     $result = $query->execute();
     if (!$result) {
         $io->error($this->trans('commands.database.log.clear.messages.clear-error'));
         return false;
     }
     $io->success($this->trans('commands.database.log.clear.messages.clear-sucess'));
     return true;
 }
Exemple #11
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $learning = $input->hasOption('learning') ? $input->getOption('learning') : false;
     $address = $input->getArgument('address');
     if (false === strpos($address, ':')) {
         $address = sprintf('%s:8088', $address);
     }
     $finder = new PhpExecutableFinder();
     if (false === ($binary = $finder->find())) {
         $io->error($this->trans('commands.server.errors.binary'));
         return;
     }
     $router = $this->getRouterPath();
     $cli = sprintf('%s %s %s %s', $binary, '-S', $address, $router);
     if ($learning) {
         $io->commentBlock($cli);
     }
     $io->success(sprintf($this->trans('commands.server.messages.executing'), $binary));
     $processBuilder = new ProcessBuilder(explode(' ', $cli));
     $process = $processBuilder->getProcess();
     $process->setWorkingDirectory($this->get('site')->getRoot());
     $process->setTty('true');
     $process->run();
     if (!$process->isSuccessful()) {
         $io->error($process->getErrorOutput());
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $vocabularies = $this->getDrupalApi()->getVocabularies();
     // Validate provided vocabularies
     $vids = $input->getArgument('vocabularies');
     $invalidVids = array_filter(array_map(function ($vid) use($vocabularies) {
         if (!isset($vocabularies[$vid])) {
             return $vid;
         } else {
             return null;
         }
     }, $vids));
     if (!empty($invalidVids)) {
         $io->error(sprintf($this->trans('commands.create.terms.messages.invalid-vocabularies'), implode(',', $invalidVids)));
         return;
     }
     $limit = $input->getOption('limit') ?: 10;
     $nameWords = $input->getOption('name-words') ?: 5;
     $createTerms = $this->getDrupalApi()->getCreateTerms();
     $terms = $createTerms->createTerm($vids, $limit, $nameWords);
     $tableHeader = [$this->trans('commands.create.terms.messages.term-id'), $this->trans('commands.create.terms.messages.vocabulary'), $this->trans('commands.create.terms.messages.name')];
     $io->table($tableHeader, $terms['success']);
     $io->success(sprintf($this->trans('commands.create.terms.messages.created-terms'), $limit));
     return;
 }
Exemple #13
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $status = $input->getOption('status');
     $type = $input->getOption('type');
     if (strtolower($status) == 'enabled') {
         $status = 1;
     } elseif (strtolower($status) == 'disabled') {
         $status = 0;
     } else {
         $status = -1;
     }
     if (strtolower($type) == 'core') {
         $type = 'core';
     } elseif (strtolower($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.status'), $this->trans('commands.module.debug.messages.package'), $this->trans('commands.module.debug.messages.schema-version'), $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.enabled') : $this->trans('commands.module.debug.messages.disabled');
         $schema_version = drupal_get_installed_schema_version($module_id) != -1 ? drupal_get_installed_schema_version($module_id) : '';
         $tableRows[] = [$module_id, $module->info['name'], $module_status, $module->info['package'], $schema_version, $module->origin];
     }
     $io->table($tableHeader, $tableRows, 'compact');
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $styles = $input->getArgument('styles');
     $result = 0;
     $imageStyle = $this->entityTypeManager->getStorage('image_style');
     $stylesNames = [];
     if (in_array('all', $styles)) {
         $styles = $imageStyle->loadMultiple();
         foreach ($styles as $style) {
             $stylesNames[] = $style->get('name');
         }
         $styles = $stylesNames;
     }
     foreach ($styles as $style) {
         try {
             $io->info(sprintf($this->trans('commands.image.styles.flush.messages.executing-flush'), $style));
             $imageStyle->load($style)->flush();
         } catch (\Exception $e) {
             watchdog_exception('image', $e);
             $io->error($e->getMessage());
             $result = 1;
         }
     }
     $io->success($this->trans('commands.image.styles.flush.messages.success'));
     return $result;
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $moduleHandler = $this->moduleHandler;
     $moduleHandler->loadInclude('locale', 'inc', 'locale.translation');
     $moduleHandler->loadInclude('locale', 'module');
     $language = $input->getArgument('language');
     $languages = $this->site->getStandardLanguages();
     if (isset($languages[$language])) {
         $langcode = $language;
     } elseif (array_search($language, $languages)) {
         $langcode = array_search($language, $languages);
     } else {
         $io->error(sprintf($this->trans('commands.locale.language.add.messages.invalid-language'), $language));
         return 1;
     }
     try {
         $language = ConfigurableLanguage::createFromLangcode($langcode);
         $language->type = LOCALE_TRANSLATION_REMOTE;
         $language->save();
         $io->info(sprintf($this->trans('commands.locale.language.add.messages.language-add-successfully'), $language->getName()));
     } catch (\Exception $e) {
         $io->error($e->getMessage());
         return 1;
     }
     return 0;
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $uid = $input->getArgument('uid');
     $account = User::load($uid);
     if (!$account) {
         // Error loading User entity.
         $io->error(sprintf($this->trans('commands.user.login.clear.attempts.errors.invalid-user'), $uid));
         return 1;
     }
     // Define event name and identifier.
     $event = 'user.failed_login_user';
     // Identifier is created by uid and IP address,
     // Then we defined a generic identifier.
     $identifier = "{$account->id()}-";
     // Retrieve current database connection.
     $database = $this->getDrupalService('database');
     $schema = $database->schema();
     $flood = $schema->findTables('flood');
     if (!$flood) {
         $io->error($this->trans('commands.user.login.clear.attempts.errors.no-flood'));
         return 1;
     }
     // Clear login attempts.
     $database->delete('flood')->condition('event', $event)->condition('identifier', $database->escapeLike($identifier) . '%', 'LIKE')->execute();
     // Command executed successful.
     $io->success(sprintf($this->trans('commands.user.login.clear.attempts.messages.successful'), $uid));
 }
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     // --module option
     $module = $input->getOption('module');
     if (!$module) {
         // @see Drupal\Console\Command\ModuleTrait::moduleQuestion
         $module = $this->moduleQuestion($output);
         $input->setOption('module', $module);
     }
     // --class option
     $class_name = $input->getOption('class');
     if (!$class_name) {
         $class_name = $io->ask($this->trans('commands.generate.plugin.type.annotation.options.class'), 'ExamplePlugin');
         $input->setOption('class', $class_name);
     }
     // --machine-name option
     $machine_name = $input->getOption('machine-name');
     if (!$machine_name) {
         $machine_name = $io->ask($this->trans('commands.generate.plugin.type.annotation.options.machine-name'), $this->getStringHelper()->camelCaseToUnderscore($class_name));
         $input->setOption('machine-name', $machine_name);
     }
     // --label option
     $label = $input->getOption('label');
     if (!$label) {
         $label = $output->ask($this->trans('commands.generate.plugin.type.annotation.options.label'), $this->getStringHelper()->camelCaseToHuman($class_name));
         $input->setOption('label', $label);
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $roles = $input->getOption('roles');
     $limit = $input->getOption('limit');
     $entityManager = $this->getEntityManager();
     $userStorage = $entityManager->getStorage('user');
     $systemRoles = $this->getDrupalApi()->getRoles();
     $entityQuery = $this->getEntityQuery();
     $query = $entityQuery->get('user');
     $query->condition('uid', 0, '>');
     $query->sort('uid');
     if ($roles) {
         $query->condition('roles', is_array($roles) ? $roles : [$roles], 'IN');
     }
     if ($limit) {
         $query->range(0, $limit);
     }
     $results = $query->execute();
     $users = $userStorage->loadMultiple($results);
     $tableHeader = [$this->trans('commands.user.debug.messages.user-id'), $this->trans('commands.user.debug.messages.username'), $this->trans('commands.user.debug.messages.roles'), $this->trans('commands.user.debug.messages.status')];
     $tableRows = [];
     foreach ($users as $userId => $user) {
         $userRoles = [];
         foreach ($user->getRoles() as $userRole) {
             $userRoles[] = $systemRoles[$userRole];
         }
         $status = $user->isActive() ? $this->trans('commands.common.status.enabled') : $this->trans('commands.common.status.disabled');
         $tableRows[] = [$userId, $user->getUsername(), implode(', ', $userRoles), $status];
     }
     $io->table($tableHeader, $tableRows);
 }
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     // --module option
     $module = $input->getOption('module');
     if (!$module) {
         // @see Drupal\Console\Command\Shared\ModuleTrait::moduleQuestion
         $module = $this->moduleQuestion($output);
         $input->setOption('module', $module);
     }
     // --class option
     $class_name = $input->getOption('class');
     if (!$class_name) {
         $class_name = $io->ask($this->trans('commands.generate.plugin.imageeffect.questions.class'), 'DefaultImageEffect');
         $input->setOption('class', $class_name);
     }
     // --label option
     $label = $input->getOption('label');
     if (!$label) {
         $label = $io->ask($this->trans('commands.generate.plugin.imageeffect.questions.label'), $this->getStringHelper()->camelCaseToHuman($class_name));
         $input->setOption('label', $label);
     }
     // --plugin-id option
     $plugin_id = $input->getOption('plugin-id');
     if (!$plugin_id) {
         $plugin_id = $io->ask($this->trans('commands.generate.plugin.imageeffect.questions.plugin-id'), $this->getStringHelper()->camelCaseToUnderscore($class_name));
         $input->setOption('plugin-id', $plugin_id);
     }
     // --description option
     $description = $input->getOption('description');
     if (!$description) {
         $description = $io->ask($this->trans('commands.generate.plugin.imageeffect.questions.description'), 'My Image Effect');
         $input->setOption('description', $description);
     }
 }
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     // --module option
     $module = $input->getOption('module');
     if (!$module) {
         // @see Drupal\Console\Command\Shared\ModuleTrait::moduleQuestion
         $module = $this->moduleQuestion($output);
         $input->setOption('module', $module);
     }
     // --class option
     $class_name = $input->getOption('class');
     if (!$class_name) {
         $class_name = $io->ask($this->trans('commands.generate.plugin.type.yaml.options.class'), 'ExamplePlugin');
         $input->setOption('class', $class_name);
     }
     // --plugin-name option
     $plugin_name = $input->getOption('plugin-name');
     if (!$plugin_name) {
         $plugin_name = $io->ask($this->trans('commands.generate.plugin.type.yaml.options.plugin-name'), $this->getStringHelper()->camelCaseToUnderscore($class_name));
         $input->setOption('plugin-name', $plugin_name);
     }
     // --plugin-file-name option
     $plugin_file_name = $input->getOption('plugin-file-name');
     if (!$plugin_file_name) {
         $plugin_file_name = $io->ask($this->trans('commands.generate.plugin.type.yaml.options.plugin-file-name'), strtr($plugin_name, '_-', '..'));
         $input->setOption('plugin-file-name', $plugin_file_name);
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $language = $input->getArgument('language');
     $format = $input->getOption('format');
     $application = $this->getApplication();
     $appRoot = $application->getDirectoryRoot();
     $languages = $application->getConfig()->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, $appRoot);
     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->getRenderHelper()->render('core/translation/stats.md.twig', $arguments));
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $output = new DrupalStyle($input, $output);
     $theme = $input->getArgument('theme');
     if (!$theme) {
         $theme_list = [];
         $themes = $this->getThemeHandler()->rebuildThemeData();
         foreach ($themes as $theme_id => $theme) {
             if (!empty($theme->info['hidden'])) {
                 continue;
             }
             if (!empty($theme->status == 0)) {
                 continue;
             }
             $theme_list[$theme_id] = $theme->getName();
         }
         $output->writeln('[+] <info>' . $this->trans('commands.theme.uninstall.messages.installed-themes') . '</info>');
         while (true) {
             $theme_name = $output->choiceNoList($this->trans('commands.theme.uninstall.questions.theme'), array_keys($theme_list));
             if (empty($theme_name)) {
                 break;
             }
             $theme_list_install[] = $theme_name;
             if (array_search($theme_name, $theme_list_install, true) >= 0) {
                 unset($theme_list[$theme_name]);
             }
         }
         $input->setArgument('theme', $theme_list_install);
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /* Register your command as a service
      *
      * Make sure you register your command class at
      * config/services/namespace.yml file and add the `console.command` tag.
      *
      * develop_example:
      *   class: Drupal\Console\Command\Develop\ExampleCommand
      *   tags:
      *     - { name: console.command }
      *
      * NOTE: Make the proper changes on the namespace and class
      *       according your new command.
      *
      * DrupalConsole extends the SymfonyStyle class to provide
      * an standardized Output Formatting Style.
      *
      * Drupal Console provides the DrupalStyle helper class:
      */
     $io = new DrupalStyle($input, $output);
     $io->simple('This text could be translatable by');
     $io->simple('adding a YAML file at "config/translations/LANGUAGE/command.name.yml"');
     /**
      *  Reading user input argument
      *  $input->getArgument('ARGUMENT_NAME');
      *
      *  Reading user input option
      *  $input->getOption('OPTION_NAME');
      */
 }
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $output = new DrupalStyle($input, $output);
     $user = $input->getArgument('user');
     if (!$user) {
         $user = $output->ask($this->trans('commands.user.password.reset.questions.user'), '', function ($uid) {
             $uid = (int) $uid;
             if (is_int($uid) && $uid > 0) {
                 return $uid;
             } else {
                 throw new \InvalidArgumentException(sprintf($this->trans('commands.user.password.reset.questions.invalid-uid'), $uid));
             }
         });
         $input->setArgument('user', $user);
     }
     $password = $input->getArgument('password');
     if (!$password) {
         $password = $output->ask($this->trans('commands.user.password.hash.questions.password'), '', function ($pass) {
             if (!empty($pass)) {
                 return $pass;
             } else {
                 throw new \InvalidArgumentException(sprintf($this->trans('commands.user.password.hash.questions.invalid-pass'), $pass));
             }
         });
         $input->setArgument('password', $password);
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     // --module option
     $module = $input->getOption('module');
     if (!$module) {
         // @see Drupal\Console\Command\ModuleTrait::moduleQuestion
         $module = $this->moduleQuestion($output);
         $input->setOption('module', $module);
     }
     // --name
     $name = $input->getOption('name');
     if (!$name) {
         $name = $io->ask($this->trans('commands.generate.command.questions.name'), sprintf('%s:default', $module));
         $input->setOption('name', $name);
     }
     // --class option
     $class = $input->getOption('class');
     if (!$class) {
         $class = $io->ask($this->trans('commands.generate.command.questions.class'), 'DefaultCommand', function ($class) {
             return $this->getValidator()->validateCommandName($class);
         });
         $input->setOption('class', $class);
     }
     // --container-aware option
     $containerAware = $input->getOption('container-aware');
     if (!$containerAware) {
         $io->confirm($this->trans('commands.generate.command.questions.container-aware'), true);
     }
     $input->setOption('container-aware', $containerAware);
 }
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $passwords = $input->getArgument('password');
     if (!$passwords) {
         $passwords = [];
         while (true) {
             $password = $io->ask($this->trans('commands.user.password.hash.questions.password'), '', function ($pass) use($passwords, $io) {
                 if (!empty($pass) || count($passwords) >= 1) {
                     if ($pass == '') {
                         return true;
                     }
                     return $pass;
                 } else {
                     $io->error(sprintf($this->trans('commands.user.password.hash.questions.invalid-pass'), $pass));
                     return false;
                 }
             });
             if ($password && !is_string($password)) {
                 break;
             }
             if (is_string($password)) {
                 $passwords[] = $password;
             }
         }
         $input->setArgument('password', $passwords);
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $modules = $input->getArgument('module');
     $composer = $input->getOption('composer');
     $simulate = $input->getOption('simulate');
     if (!$composer) {
         $io->error($this->trans('commands.module.update.messages.only-composer'));
         return 1;
     }
     if (!$modules) {
         $io->error($this->trans('commands.module.update.messages.missing-module'));
         return 1;
     }
     if (count($modules) > 1) {
         $modules = " drupal/" . implode(" drupal/", $modules);
     } else {
         $modules = " drupal/" . current($modules);
     }
     if ($composer) {
         // Register composer repository
         $command = "composer config repositories.drupal composer https://packagist.drupal-composer.org";
         $this->shellProcess->exec($command, $this->root);
         $command = 'composer update ' . $modules . ' --optimize-autoloader --prefer-dist --no-dev --root-reqs ';
         if ($simulate) {
             $command .= " --dry-run";
         }
         if ($this->shellProcess->exec($command, $this->root)) {
             $io->success(sprintf($this->trans('commands.module.update.messages.composer'), trim($modules)));
         }
     }
     return 0;
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $modules = $input->getArgument('module');
     if (!$this->lock->acquire('cron', 900.0)) {
         $io->warning($this->trans('commands.cron.execute.messages.lock'));
         return 1;
     }
     if (in_array('all', $modules)) {
         $modules = $this->moduleHandler->getImplementations('cron');
     }
     foreach ($modules as $module) {
         if (!$this->moduleHandler->implementsHook($module, 'cron')) {
             $io->warning(sprintf($this->trans('commands.cron.execute.messages.module-invalid'), $module));
             continue;
         }
         try {
             $io->info(sprintf($this->trans('commands.cron.execute.messages.executing-cron'), $module));
             $this->moduleHandler->invoke($module, 'cron');
         } catch (\Exception $e) {
             watchdog_exception('cron', $e);
             $io->error($e->getMessage());
         }
     }
     $this->state->set('system.cron_last', REQUEST_TIME);
     $this->lock->release('cron');
     $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']);
     $io->success($this->trans('commands.cron.execute.messages.success'));
     return 0;
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $state = $this->getState();
     $mode = $input->getArgument('mode');
     $stateName = 'system.maintenance_mode';
     $modeMessage = null;
     $cacheRebuild = true;
     if ('ON' === strtoupper($mode)) {
         $state->set($stateName, true);
         $modeMessage = 'commands.site.maintenance.messages.maintenance-on';
     }
     if ('OFF' === strtoupper($mode)) {
         $state->set($stateName, false);
         $modeMessage = 'commands.site.maintenance.messages.maintenance-off';
     }
     if ($modeMessage === null) {
         $modeMessage = 'commands.site.maintenance.errors.invalid-mode';
         $cacheRebuild = false;
     }
     $io->info($this->trans($modeMessage));
     if ($cacheRebuild) {
         $this->getChain()->addCommand('cache:rebuild', ['cache' => 'all']);
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $learning = $input->hasOption('learning') ? $input->getOption('learning') : false;
     $address = $this->validatePort($input->getArgument('address'));
     $finder = new PhpExecutableFinder();
     if (false === ($binary = $finder->find())) {
         $io->error($this->trans('commands.server.errors.binary'));
         return;
     }
     $router = $this->getRouterPath();
     $cli = sprintf('%s %s %s %s', $binary, '-S', $address, $router);
     if ($learning) {
         $io->commentBlock($cli);
     }
     $io->success(sprintf($this->trans('commands.server.messages.executing'), $binary));
     $processBuilder = new ProcessBuilder(explode(' ', $cli));
     $process = $processBuilder->getProcess();
     $process->setWorkingDirectory($this->appRoot);
     if ('\\' !== DIRECTORY_SEPARATOR && file_exists('/dev/tty') && is_readable('/dev/tty')) {
         $process->setTty('true');
     } else {
         $process->setTimeout(null);
     }
     $process->run();
     if (!$process->isSuccessful()) {
         $io->error($process->getErrorOutput());
     }
 }