本文整理汇总了PHP中Drupal\Console\Style\DrupalStyle::choiceNoList方法的典型用法代码示例。如果您正苦于以下问题:PHP DrupalStyle::choiceNoList方法的具体用法?PHP DrupalStyle::choiceNoList怎么用?PHP DrupalStyle::choiceNoList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Console\Style\DrupalStyle
的用法示例。
在下文中一共展示了DrupalStyle::choiceNoList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: interact
/**
* {@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: interact
/**
* {@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: execute
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: interact
/**
* {@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: execute
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: interact
/**
* {@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: execute
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: moduleQuestion
/**
* @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: interact
/**
* {@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: interact
/**
* {@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);
}
}
示例11: interact
/**
* {@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);
}
}
示例12: interact
/**
* {@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);
}
}
示例13: interact
/**
* {@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);
}
}
示例14: moduleQuestion
/**
* @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;
}
示例15: modulesUninstallQuestion
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;
}