コード例 #1
0
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $name = $input->getArgument('name');
     $configFactory = $this->getDrupalService('config.factory');
     $names = $configFactory->listAll();
     if ($name) {
         if (!in_array($name, $names)) {
             $io->warning(sprintf($this->trans('commands.config.override.messages.invalid-name'), $name));
             $name = null;
         }
     }
     if (!$name) {
         $name = $io->choiceNoList($this->trans('commands.config.override.questions.name'), $names);
         $input->setArgument('name', $name);
     }
     $key = $input->getArgument('key');
     if (!$key) {
         $configStorage = $this->getDrupalService('config.storage');
         if ($configStorage->exists($name)) {
             $configuration = $configStorage->read($name);
         }
         $key = $io->choiceNoList($this->trans('commands.config.override.questions.key'), array_keys($configuration));
         $input->setArgument('key', $key);
     }
     $value = $input->getArgument('value');
     if (!$value) {
         $value = $io->ask($this->trans('commands.config.override.questions.value'));
         $input->setArgument('value', $value);
     }
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $type = $input->getArgument('type');
     if (!$type) {
         $type = $io->choiceNoList($this->trans('commands.config.delete.arguments.type'), ['active', 'staging'], 'active');
         $input->setArgument('type', $type);
     }
     $name = $input->getArgument('name');
     if (!$name) {
         $name = $io->choiceNoList($this->trans('commands.config.delete.arguments.name'), $this->getAllConfigNames(), 'all');
         $input->setArgument('name', $name);
     }
 }
コード例 #3
0
 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;
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $output = new DrupalStyle($input, $output);
     $module = $input->getArgument('module');
     if (!$module) {
         $moduleList = [];
         $modules = system_rebuild_module_data();
         foreach ($modules as $moduleId => $module) {
             if ($module->status == 1) {
                 continue;
             }
             $moduleList[$moduleId] = $module->info['name'];
         }
         $output->writeln($this->trans('commands.module.install.messages.disabled-modules'));
         while (true) {
             $moduleName = $output->choiceNoList($this->trans('commands.module.install.questions.module'), array_keys($moduleList), null, true);
             if (empty($moduleName)) {
                 break;
             }
             $moduleListInstall[] = $moduleName;
             if (array_search($moduleName, $moduleListInstall, true) >= 0) {
                 unset($moduleList[$moduleName]);
             }
         }
         $input->setArgument('module', $moduleListInstall);
     }
     $overwrite_config = $input->getOption('overwrite-config');
     $input->setOption('overwrite-config', $overwrite_config);
 }
コード例 #5
0
 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->getTranslator());
     $input->setArgument('resource-id', $resource_id);
     // Calculate states available by resource and generate the question
     $plugin = $this->pluginManagerRest->getInstance(['id' => $resource_id]);
     $states = $plugin->availableMethods();
     $state = $io->choice($this->trans('commands.rest.enable.arguments.states'), $states);
     $io->writeln($this->trans('commands.rest.enable.messages.selected-state') . ' ' . $state);
     // 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));
     $rest_settings = $this->getRestDrupalConfig();
     $rest_settings[$resource_id][$state]['supported_formats'] = $formats;
     $rest_settings[$resource_id][$state]['supported_auth'] = $authenticationProvidersSelected;
     $config = $this->configFactory->getEditable('rest.settings');
     $config->set('resources', $rest_settings);
     $config->save();
     return 0;
 }
コード例 #6
0
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = 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();
         }
         $io->info($this->trans('commands.theme.uninstall.messages.installed-themes'));
         while (true) {
             $theme_name = $io->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);
     }
 }
コード例 #7
0
 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->getTranslator());
     $input->setArgument('resource-id', $resource_id);
     // Calculate states available by resource and generate the question
     $resourcePluginManager = $this->getPluginManagerRest();
     $plugin = $resourcePluginManager->getInstance(array('id' => $resource_id));
     $states = $plugin->availableMethods();
     $state = $io->choice($this->trans('commands.rest.enable.arguments.states'), $states);
     $io->writeln($this->trans('commands.rest.enable.messages.selected-state') . ' ' . $state);
     // Get serializer formats available and generate the question.
     $serializedFormats = $this->getSerializerFormats();
     $formats = $io->choice($this->trans('commands.rest.enable.messages.formats'), $serializedFormats, 0, true);
     $io->writeln($this->trans('commands.rest.enable.messages.selected-formats') . ' ' . implode(', ', $formats));
     // Get Authentication Provider and generate the question
     $authenticationProviders = $this->getAuthenticationProviders();
     $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));
     $rest_settings = $this->getRestDrupalConfig();
     $rest_settings[$resource_id][$state]['supported_formats'] = $formats;
     $rest_settings[$resource_id][$state]['supported_auth'] = $authenticationProvidersSelected;
     $config = $this->getConfigFactory()->getEditable('rest.settings');
     $config->set('resources', $rest_settings);
     $config->save();
     // Run cache rebuild to enable rest routing
     $this->getChain()->addCommand('cache:rebuild', ['cache' => 'all']);
 }
コード例 #8
0
ファイル: ModuleTrait.php プロジェクト: ostark/DrupalConsole
 /**
  * @param \Drupal\Console\Style\DrupalStyle $io
  * @return string
  * @throws \Exception
  */
 public function moduleQuestion(DrupalStyle $io)
 {
     $modules = $this->getSite()->getModules(false, false, false, true, true);
     if (empty($modules)) {
         throw new \Exception('No modules available, execute `generate:module` command to generate one.');
     }
     $module = $io->choiceNoList($this->trans('commands.common.questions.module'), $modules);
     return $module;
 }
コード例 #9
0
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $module = $input->getArgument('module');
     $modules = $this->getSite()->getModules(true, true, false, true, true, true);
     if (!$module) {
         $module = $io->choiceNoList($this->trans('commands.module.uninstall.questions.module'), $modules, true);
         $input->setArgument('module', $module);
     }
 }
コード例 #10
0
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $name = $input->getArgument('name');
     if (!$name) {
         $names = array_keys($this->keyValue->get('state')->getAll());
         $name = $io->choiceNoList($this->trans('commands.state.delete.arguments.name'), $names);
         $input->setArgument('name', $name);
     }
 }
コード例 #11
0
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $viewId = $input->getArgument('view-id');
     if (!$viewId) {
         $views = $this->getDrupalService('entity.query')->get('view')->condition('status', 1)->execute();
         $viewId = $io->choiceNoList($this->trans('commands.views.debug.arguments.view-id'), $views);
         $input->setArgument('view-id', $viewId);
     }
 }
コード例 #12
0
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $cache = $input->getArgument('cache');
     if (!$cache) {
         $cacheKeys = array_keys($this->drupalApi->getCaches());
         $cache = $io->choiceNoList($this->trans('commands.cache.rebuild.questions.cache'), $cacheKeys, 'all');
         $input->setArgument('cache', $cache);
     }
 }
コード例 #13
0
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $name = $input->getArgument('name');
     if (!$name) {
         $configFactory = $this->getService('config.factory');
         $names = $configFactory->listAll();
         $name = $io->choiceNoList($this->trans('commands.config.delete.arguments.name'), $names);
         $input->setArgument('name', $name);
     }
 }
コード例 #14
0
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $cache = $input->getArgument('cache');
     if (!$cache) {
         $validators = $this->getApplication()->getValidator();
         $caches = $validators->getCaches();
         $cache_keys = array_keys($caches);
         $cache = $io->choiceNoList($this->trans('commands.cache.rebuild.questions.cache'), $cache_keys, 'all');
         $input->setArgument('cache', $cache);
     }
 }
コード例 #15
0
 /**
  * @param \Drupal\Console\Style\DrupalStyle $io
  * @param bool|true                         $showProfile
  * @return string
  * @throws \Exception
  */
 public function moduleQuestion(DrupalStyle $io, $showProfile = true)
 {
     $modules = $this->extensionManager->discoverModules()->showInstalled()->showUninstalled()->showNoCore()->getList(true);
     if ($showProfile) {
         $profiles = $this->extensionManager->discoverModules()->showInstalled()->showNoCore()->showCore()->getList(true);
         $modules = array_merge($modules, $profiles);
     }
     if (empty($modules)) {
         throw new \Exception('No modules available, execute `generate:module` command to generate one.');
     }
     $module = $io->choiceNoList($this->trans('commands.common.questions.module'), $modules);
     return $module;
 }
コード例 #16
0
 public function modulesUninstallQuestion(DrupalStyle $io)
 {
     $moduleList = [];
     $modules = $this->extensionManager->discoverModules()->showInstalled()->showNoCore()->showCore()->getList(true);
     while (true) {
         $moduleName = $io->choiceNoList($this->trans('commands.module.uninstall.questions.module'), $modules, null, true);
         if (empty($moduleName)) {
             break;
         }
         $moduleList[] = $moduleName;
     }
     return $moduleList;
 }
コード例 #17
0
 public function modulesUninstallQuestion(DrupalStyle $io)
 {
     $moduleList = [];
     $modules = $this->getApplication()->getSite()->getModules(true, true, false, true, true, true);
     while (true) {
         $moduleName = $io->choiceNoList($this->trans('commands.module.uninstall.questions.module'), $modules, null, true);
         if (empty($moduleName)) {
             break;
         }
         $moduleList[] = $moduleName;
     }
     return $moduleList;
 }
コード例 #18
0
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $key = $input->getArgument('key');
     $value = $input->getArgument('value');
     if (!$key) {
         $names = array_keys($this->keyValue->get('state')->getAll());
         $key = $io->choiceNoList($this->trans('commands.state.override.arguments.key'), $names);
         $input->setArgument('key', $key);
     }
     if (!$value) {
         $value = $io->ask($this->trans('commands.state.override.arguments.value'));
         $input->setArgument('value', $value);
     }
 }
コード例 #19
0
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $name = $input->getArgument('name');
     if (!$name) {
         $configFactory = $this->getDrupalService('config.factory');
         $names = $configFactory->listAll();
         $name = $io->choiceNoList($this->trans('commands.config.import.single.questions.name'), $names);
         $input->setArgument('name', $name);
     }
     $file = $input->getArgument('file');
     if (!$file) {
         $file = $io->ask($this->trans('commands.config.import.single.questions.file'));
         $input->setArgument('file', $file);
     }
 }
コード例 #20
0
 public function modulesQuestion(DrupalStyle $io)
 {
     $moduleList = [];
     $modules = $this->getSite()->getModules(true, false, true, true, true, true);
     while (true) {
         $moduleName = $io->choiceNoList($this->trans('commands.module.install.questions.module'), $modules, null, true);
         if (empty($moduleName)) {
             break;
         }
         $moduleList[] = $moduleName;
         if (array_search($moduleName, $moduleList, true) >= 0) {
             unset($modules[array_search($moduleName, $modules)]);
         }
     }
     return $moduleList;
 }
コード例 #21
0
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $this->metadata = [];
     $io = new DrupalStyle($input, $output);
     $moduleHandler = $this->getModuleHandler();
     $drupal = $this->getDrupalHelper();
     $questionHelper = $this->getQuestionHelper();
     // --module option
     $module = $input->getOption('module');
     if (!$module) {
         // @see Drupal\Console\Command\ModuleTrait::moduleQuestion
         $module = $this->moduleQuestion($output);
     }
     $input->setOption('module', $module);
     // --form-id option
     $formId = $input->getOption('form-id');
     if (!$formId) {
         $forms = [];
         // Get form ids from webprofiler
         if ($moduleHandler->moduleExists('webprofiler')) {
             $output->writeln('<info>' . $this->trans('commands.generate.form.alter.messages.loading-forms') . '</info>');
             $forms = $this->getWebprofilerForms();
         }
         if (!empty($forms)) {
             $formId = $io->choiceNoList($this->trans('commands.generate.form.alter.options.form-id'), array_keys($forms));
         }
     }
     if ($moduleHandler->moduleExists('webprofiler') && isset($forms[$formId])) {
         $this->metadata['class'] = $forms[$formId]['class']['class'];
         $this->metadata['method'] = $forms[$formId]['class']['method'];
         $this->metadata['file'] = str_replace($drupal->getRoot(), '', $forms[$formId]['class']['file']);
         $formItems = array_keys($forms[$formId]['form']);
         $question = new ChoiceQuestion($this->trans('commands.generate.form.alter.messages.hide-form-elements'), array_combine($formItems, $formItems), '0');
         $question->setMultiselect(true);
         $question->setValidator(function ($answer) {
             return $answer;
         });
         $formItemsToHide = $questionHelper->ask($input, $output, $question);
         $this->metadata['unset'] = array_filter(array_map('trim', explode(',', $formItemsToHide)));
     }
     $input->setOption('form-id', $formId);
     $output->writeln($this->trans('commands.generate.form.alter.messages.inputs'));
     // @see Drupal\Console\Command\FormTrait::formQuestion
     $form = $this->formQuestion($output);
     $input->setOption('inputs', $form);
 }
コード例 #22
0
 /**
  * @param DrupalStyle $output
  *
  * @return mixed
  */
 public function permissionQuestion(DrupalStyle $output)
 {
     $permissions = [];
     $boolOrNone = ['true', 'false', 'none'];
     while (true) {
         $permission = $output->ask($this->trans('commands.generate.permission.questions.permission'), 'access content');
         $title = $output->ask($this->trans('commands.generate.permission.questions.title'), 'Access content');
         $description = $output->ask($this->trans('commands.generate.permission.questions.description'), 'Allow access to my content');
         $restrictAccess = $output->choiceNoList($this->trans('commands.generate.permission.questions.restrict-access'), $boolOrNone, 'none');
         $permission = $this->stringConverter->camelCaseToLowerCase($permission);
         $title = $this->stringConverter->anyCaseToUcFirst($title);
         array_push($permissions, ['permission' => $permission, 'title' => $title, 'description' => $description, 'restrict_access' => $restrictAccess]);
         if (!$output->confirm($this->trans('commands.generate.permission.questions.add'), true)) {
             break;
         }
     }
     return $permissions;
 }
コード例 #23
0
ファイル: MenuTrait.php プロジェクト: mnico/DrupalConsole
 /**
  * @param \Drupal\Console\Style\DrupalStyle $io
  * @param string                            $className The form class name
  * @return string
  * @throws \Exception
  */
 public function menuQuestion(DrupalStyle $io, $className)
 {
     if ($io->confirm($this->trans('commands.generate.form.questions.menu_link_gen'), true)) {
         // now we need to ask them where to gen the form
         // get the route
         $menu_options = ['menu_link_gen' => true];
         $menu_link_title = $io->ask($menu_link_title = $this->trans('commands.generate.form.questions.menu_link_title'), $className);
         $menuLinkFile = sprintf('%s/core/modules/system/system.links.menu.yml', $this->getSite()->getSiteRoot());
         $config = $this->getApplication()->getConfig();
         $menuLinkContent = $config->getFileContents($menuLinkFile);
         $menu_parent = $io->choiceNoList($menu_parent = $this->trans('commands.generate.form.questions.menu_parent'), array_keys($menuLinkContent), 'system.admin_config_system');
         $menu_link_desc = $io->ask($menu_link_desc = $this->trans('commands.generate.form.questions.menu_link_desc'), 'A description for the menu entry');
         $menu_options['menu_link_title'] = $menu_link_title;
         $menu_options['menu_parent'] = $menu_parent;
         $menu_options['menu_link_desc'] = $menu_link_desc;
         return $menu_options;
     }
 }
コード例 #24
0
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $module = $input->getArgument('module');
     if (!$module) {
         $moduleList = [];
         $modules = $this->getSite()->getModules(true, false, true, true, true, true);
         while (true) {
             $moduleName = $io->choiceNoList($this->trans('commands.module.install.questions.module'), $modules, null, true);
             if (empty($moduleName)) {
                 break;
             }
             $moduleList[] = $moduleName;
             if (array_search($moduleName, $moduleList, true) >= 0) {
                 unset($modules[array_search($moduleName, $modules)]);
             }
         }
         $input->setArgument('module', $moduleList);
     }
 }
コード例 #25
0
 /**
  * @param DrupalStyle $io
  *
  * @return mixed
  */
 public function eventsQuestion(DrupalStyle $io)
 {
     $eventCollection = [];
     $io->info($this->trans('commands.common.questions.events.message'));
     $events = $this->getEvents();
     while (true) {
         $event = $io->choiceNoList($this->trans('commands.common.questions.events.name'), $events, null, true);
         if (empty($event)) {
             break;
         }
         $callbackSuggestion = str_replace('.', '_', $event);
         $callback = $io->ask($this->trans('commands.generate.event.subscriber.questions.callback-name'), $callbackSuggestion);
         $eventCollection[$event] = $callback;
         $eventKey = array_search($event, $events, true);
         if ($eventKey >= 0) {
             unset($events[$eventKey]);
         }
     }
     return $eventCollection;
 }
コード例 #26
0
 /**
  * @param DrupalStyle $io
  *
  * @return mixed
  */
 public function servicesQuestion(DrupalStyle $io)
 {
     if ($io->confirm($this->trans('commands.common.questions.services.confirm'), false)) {
         $service_collection = [];
         $io->writeln($this->trans('commands.common.questions.services.message'));
         $services = $this->getServices();
         while (true) {
             $service = $io->choiceNoList($this->trans('commands.common.questions.services.name'), $services, null, true);
             $service = trim($service);
             if (empty($service)) {
                 break;
             }
             array_push($service_collection, $service);
             $service_key = array_search($service, $services, true);
             if ($service_key >= 0) {
                 unset($services[$service_key]);
             }
         }
         return $service_collection;
     }
 }
コード例 #27
0
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $stringUtils = $this->getStringHelper();
     $drupal = $this->getDrupalHelper();
     $drupalRoot = $drupal->getRoot();
     // --base-theme option.
     $base_theme = $input->getOption('theme');
     if (!$base_theme) {
         $themeHandler = $this->getThemeHandler();
         $themes = $themeHandler->rebuildThemeData();
         $themes['classy'] = '';
         uasort($themes, 'system_sort_modules_by_info_name');
         $base_theme = $io->choiceNoList($this->trans('commands.generate.breakpoint.questions.theme'), array_keys($themes));
         $input->setOption('theme', $base_theme);
     }
     // --breakpoints option.
     $breakpoints = $input->getOption('breakpoints');
     if (!$breakpoints) {
         $breakpoints = $this->breakpointQuestion($output);
         $input->setOption('breakpoints', $breakpoints);
     }
 }
コード例 #28
0
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     // profile option
     $profile = $input->getArgument('profile');
     if (!$profile) {
         $profiles = $this->getProfiles();
         $profile = $io->choice($this->trans('commands.site.install.questions.profile'), array_values($profiles));
         $input->setArgument('profile', array_search($profile, $profiles));
     }
     // --langcode option
     $langcode = $input->getOption('langcode');
     if (!$langcode) {
         $languages = $this->getLanguages();
         $defaultLanguage = $this->getDefaultLanguage();
         $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) {
             $dbType = $this->dbTypeQuestion($io);
             $input->setOption('db-type', $dbType);
         }
         // --db-file option
         $dbFile = $input->getOption('db-file');
         if ($dbType == 'sqlite' && !$dbFile) {
             $dbFile = $this->dbFileQuestion($io);
             $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
     $site_name = $input->getOption('site-name');
     if (!$site_name) {
         $site_name = $io->ask($this->trans('commands.site.install.questions.site-name'), 'Drupal 8 Site Install');
         $input->setOption('site-name', $site_name);
     }
     // --site-mail option
     $site_mail = $input->getOption('site-mail');
     if (!$site_mail) {
         $site_mail = $io->ask($this->trans('commands.site.install.questions.site-mail'), '*****@*****.**');
         $input->setOption('site-mail', $site_mail);
     }
     // --account-name option
     $account_name = $input->getOption('account-name');
     if (!$account_name) {
         $account_name = $io->ask($this->trans('commands.site.install.questions.account-name'), 'admin');
         $input->setOption('account-name', $account_name);
     }
     // --account-mail option
     $account_mail = $input->getOption('account-mail');
     if (!$account_mail) {
         $account_mail = $io->ask($this->trans('commands.site.install.questions.account-mail'), '*****@*****.**');
         $input->setOption('account-mail', $account_mail);
     }
     // --account-pass option
     $account_pass = $input->getOption('account-pass');
     if (!$account_pass) {
         $account_pass = $io->askHidden($this->trans('commands.site.install.questions.account-pass'));
         $input->setOption('account-pass', $account_pass);
     }
 }
コード例 #29
0
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     try {
         $theme = $input->getOption('theme') ? $this->validator->validateModuleName($input->getOption('theme')) : null;
     } catch (\Exception $error) {
         $io->error($error->getMessage());
         return;
     }
     if (!$theme) {
         $validators = $this->validator;
         $theme = $io->ask($this->trans('commands.generate.theme.questions.theme'), '', function ($theme) use($validators) {
             return $validators->validateModuleName($theme);
         });
         $input->setOption('theme', $theme);
     }
     try {
         $machine_name = $input->getOption('machine-name') ? $this->validator->validateModule($input->getOption('machine-name')) : null;
     } catch (\Exception $error) {
         $io->error($error->getMessage());
         return;
     }
     if (!$machine_name) {
         $machine_name = $io->ask($this->trans('commands.generate.module.questions.machine-name'), $this->stringConverter->createMachineName($theme), function ($machine_name) use($validators) {
             return $validators->validateMachineName($machine_name);
         });
         $input->setOption('machine-name', $machine_name);
     }
     $theme_path = $input->getOption('theme-path');
     if (!$theme_path) {
         $drupalRoot = $this->appRoot;
         $theme_path = $io->ask($this->trans('commands.generate.theme.questions.theme-path'), '/themes/custom', function ($theme_path) use($drupalRoot, $machine_name) {
             $theme_path = ($theme_path[0] != '/' ? '/' : '') . $theme_path;
             $full_path = $drupalRoot . $theme_path . '/' . $machine_name;
             if (file_exists($full_path)) {
                 throw new \InvalidArgumentException(sprintf($this->trans('commands.generate.theme.errors.directory-exists'), $full_path));
             } else {
                 return $theme_path;
             }
         });
         $input->setOption('theme-path', $theme_path);
     }
     $description = $input->getOption('description');
     if (!$description) {
         $description = $io->ask($this->trans('commands.generate.theme.questions.description'), 'My Awesome theme');
         $input->setOption('description', $description);
     }
     $package = $input->getOption('package');
     if (!$package) {
         $package = $io->ask($this->trans('commands.generate.theme.questions.package'), 'Other');
         $input->setOption('package', $package);
     }
     $core = $input->getOption('core');
     if (!$core) {
         $core = $io->ask($this->trans('commands.generate.theme.questions.core'), '8.x');
         $input->setOption('core', $core);
     }
     $base_theme = $input->getOption('base-theme');
     if (!$base_theme) {
         $themes = $this->themeHandler->rebuildThemeData();
         $themes['false'] = '';
         uasort($themes, 'system_sort_modules_by_info_name');
         $base_theme = $io->choiceNoList($this->trans('commands.generate.theme.options.base-theme'), array_keys($themes));
         $input->setOption('base-theme', $base_theme);
     }
     $global_library = $input->getOption('global-library');
     if (!$global_library) {
         $global_library = $io->ask($this->trans('commands.generate.theme.questions.global-library'), 'global-styling');
         $input->setOption('global-library', $global_library);
     }
     // --regions option.
     $regions = $input->getOption('regions');
     if (!$regions) {
         if ($io->confirm($this->trans('commands.generate.theme.questions.regions'), true)) {
             // @see \Drupal\Console\Command\Shared\ThemeRegionTrait::regionQuestion
             $regions = $this->regionQuestion($io);
             $input->setOption('regions', $regions);
         }
     }
     // --breakpoints option.
     $breakpoints = $input->getOption('breakpoints');
     if (!$breakpoints) {
         if ($io->confirm($this->trans('commands.generate.theme.questions.breakpoints'), true)) {
             // @see \Drupal\Console\Command\Shared\ThemeRegionTrait::regionQuestion
             $breakpoints = $this->breakpointQuestion($io);
             $input->setOption('breakpoints', $breakpoints);
         }
     }
 }
コード例 #30
0
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $config_types = $this->getConfigTypes();
     $config_name = $input->getArgument('config-name');
     if (!$config_name) {
         $config_type = $io->choiceNoList($this->trans('commands.config.export.single.questions.config-type'), array_keys($config_types), $this->trans('commands.config.export.single.options.simple-configuration'));
         $config_names = $this->getConfigNames($config_type);
         $config_name = $io->choiceNoList($this->trans('commands.config.export.single.questions.config-name'), array_keys($config_names));
         if ($config_type !== 'system.simple') {
             $definition = $this->entityTypeManager->getDefinition($config_type);
             $config_name = $definition->getConfigPrefix() . '.' . $config_name;
         }
         $input->setArgument('config-name', $config_name);
     }
     $module = $input->getOption('module');
     if ($module) {
         $optionalConfig = $input->getOption('optional-config');
         if (!$optionalConfig) {
             $optionalConfig = $io->confirm($this->trans('commands.config.export.single.questions.optional-config'), true);
             $input->setOption('optional-config', $optionalConfig);
         }
     }
 }