当前位置: 首页>>代码示例>>PHP>>正文


PHP DrupalStyle::confirm方法代码示例

本文整理汇总了PHP中Drupal\Console\Style\DrupalStyle::confirm方法的典型用法代码示例。如果您正苦于以下问题:PHP DrupalStyle::confirm方法的具体用法?PHP DrupalStyle::confirm怎么用?PHP DrupalStyle::confirm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\Console\Style\DrupalStyle的用法示例。


在下文中一共展示了DrupalStyle::confirm方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: interact

 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     parent::interact($input, $output);
     $io = new DrupalStyle($input, $output);
     // --bundle-of option
     $bundle_of = $input->getOption('has-bundles');
     if (!$bundle_of) {
         $bundle_of = $io->confirm($this->trans('commands.generate.entity.content.questions.has-bundles'), false);
         $input->setOption('has-bundles', $bundle_of);
     }
     // --is-translatable option
     $is_translatable = $io->confirm($this->trans('commands.generate.entity.content.questions.is-translatable'), true);
     $input->setOption('is-translatable', $is_translatable);
 }
开发者ID:mnico,项目名称:DrupalConsole,代码行数:17,代码来源:EntityContentCommand.php

示例2: interact

 /**
  * {@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);
 }
开发者ID:blasoliva,项目名称:DrupalConsole,代码行数:34,代码来源:CommandCommand.php

示例3: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $application = $this->getApplication();
     $manifest = $input->getOption('manifest') ?: 'http://drupalconsole.com/manifest.json';
     $currentVersion = $input->getOption('current-version') ?: $application->getVersion();
     $major = $input->getOption('major');
     if (!extension_loaded('Phar') || !\Phar::running(false)) {
         $io->error($this->trans('commands.self-update.messages.not-phar'));
         $io->block($this->trans('commands.self-update.messages.instructions'));
         return 1;
     }
     $io->info(sprintf($this->trans('commands.self-update.messages.check'), $currentVersion));
     $updater = new Updater(null, false);
     $strategy = new ManifestStrategy($currentVersion, $major, $manifest);
     $updater->setStrategyObject($strategy);
     if (!$updater->hasUpdate()) {
         $io->info(sprintf($this->trans('commands.self-update.messages.current-version'), $currentVersion));
         return 0;
     }
     $oldVersion = $updater->getOldVersion();
     $newVersion = $updater->getNewVersion();
     if (!$io->confirm(sprintf($this->trans('commands.self-update.questions.update'), $oldVersion, $newVersion), true)) {
         return 1;
     }
     $io->comment(sprintf($this->trans('commands.self-update.messages.update'), $newVersion));
     $updater->update();
     $io->success(sprintf($this->trans('commands.self-update.messages.success'), $oldVersion, $newVersion));
     // Errors appear if new classes are instantiated after this stage
     // (namely, Symfony's ConsoleTerminateEvent). This suggests PHP
     // can't read files properly from the overwritten Phar, or perhaps it's
     // because the autoloader's name has changed. We avoid the problem by
     // terminating now.
     exit;
 }
开发者ID:blasoliva,项目名称:DrupalConsole,代码行数:38,代码来源:UpdateCommand.php

示例4: confirmGeneration

 /**
  * @param DrupalStyle $io
  *
  * @return bool
  */
 public function confirmGeneration(DrupalStyle $io)
 {
     $confirmation = $io->confirm($this->trans('commands.common.questions.confirm'), true);
     if (!$confirmation) {
         $io->warning($this->trans('commands.common.messages.canceled'));
     }
     return $confirmation;
 }
开发者ID:stevepatz,项目名称:DrupalConsole,代码行数:13,代码来源:ConfirmationTrait.php

示例5: interact

 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     parent::interact($input, $output);
     $output = new DrupalStyle($input, $output);
     // --bundle-of option
     $bundle_of = $input->getOption('has-bundles');
     if (!$bundle_of) {
         $bundle_of = $output->confirm($this->trans('commands.generate.entity.questions.has-bundles'), false);
         $input->setOption('has-bundles', $bundle_of);
     }
 }
开发者ID:dustinleblanc,项目名称:DrupalConsole,代码行数:14,代码来源:EntityContentCommand.php

示例6: regionQuestion

 /**
  * @param DrupalStyle $io
  *
  * @return mixed
  */
 public function regionQuestion(DrupalStyle $io)
 {
     $validators = $this->validator;
     $regions = [];
     while (true) {
         $regionName = $io->ask($this->trans('commands.generate.theme.questions.region-name'), 'Content');
         $regionMachineName = $this->stringConverter->createMachineName($regionName);
         $regionMachineName = $io->ask($this->trans('commands.generate.theme.questions.region-machine-name'), $regionMachineName, function ($regionMachineName) use($validators) {
             return $validators->validateMachineName($regionMachineName);
         });
         array_push($regions, ['region_name' => $regionName, 'region_machine_name' => $regionMachineName]);
         if (!$io->confirm($this->trans('commands.generate.theme.questions.region-add'), true)) {
             break;
         }
     }
     return $regions;
 }
开发者ID:ibonelli,项目名称:DrupalConsole,代码行数:22,代码来源:ThemeRegionTrait.php

示例7: menuQuestion

 /**
  * @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;
     }
 }
开发者ID:mnico,项目名称:DrupalConsole,代码行数:24,代码来源:MenuTrait.php

示例8: permissionQuestion

 /**
  * @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;
 }
开发者ID:ibonelli,项目名称:DrupalConsole,代码行数:23,代码来源:PermissionTrait.php

示例9: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $modules = $input->getArgument('module');
     $overwriteConfig = $input->getOption('overwrite-config');
     $validator = $this->getValidator();
     $moduleInstaller = $this->getModuleInstaller();
     $invalidModules = $validator->getInvalidModules($modules);
     if ($invalidModules) {
         $io->error(sprintf($this->trans('commands.module.install.messages.missing'), implode(', ', $modules), implode(', ', $invalidModules)));
         return;
     }
     $unInstalledModules = $validator->getUninstalledModules($modules);
     if (!$unInstalledModules) {
         $io->warning($this->trans('commands.module.install.messages.nothing'));
         return;
     }
     $dependencies = $this->calculateDependencies($unInstalledModules);
     $missingDependencies = $validator->getInvalidModules($dependencies);
     if ($missingDependencies) {
         $io->error(sprintf($this->trans('commands.module.install.messages.missing-dependencies'), implode(', ', $modules), implode(', ', $missingDependencies)));
         return true;
     }
     if ($dependencies) {
         if (!$io->confirm(sprintf($this->trans('commands.module.install.messages.dependencies'), implode(', ', $dependencies)), false)) {
             return;
         }
     }
     $moduleList = array_merge($unInstalledModules, $dependencies);
     try {
         $moduleInstaller->install($moduleList);
         $io->success(sprintf($this->trans('commands.module.install.messages.success'), implode(', ', $moduleList)));
     } catch (PreExistingConfigException $e) {
         $this->overwriteConfig($io, $e, $moduleList, $overwriteConfig);
         return;
     } catch (\Exception $e) {
         $io->error($e->getMessage());
         return;
     }
     // Run cache rebuild to see changes in Web UI
     $this->getChain()->addCommand('cache:rebuild', ['cache' => 'all']);
 }
开发者ID:tstoeckler,项目名称:DrupalConsole,代码行数:45,代码来源:InstallCommand.php

示例10: interact

 /**
  * {@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.service.questions.service-name'), $module . '.default');
         $input->setOption('name', $name);
     }
     // --class option
     $class = $input->getOption('class');
     if (!$class) {
         $class = $io->ask($this->trans('commands.generate.service.questions.class'), 'DefaultService');
         $input->setOption('class', $class);
     }
     // --interface option
     $interface = $input->getOption('interface');
     if (!$interface) {
         $interface = $io->confirm($this->trans('commands.generate.service.questions.interface'), true);
         $input->setOption('interface', $interface);
     }
     // --services option
     $services = $input->getOption('services');
     if (!$services) {
         // @see Drupal\Console\Command\Shared\ServicesTrait::servicesQuestion
         $services = $this->servicesQuestion($output);
         $input->setOption('services', $services);
     }
     // --path_service option
     $path_service = $input->getOption('path_service');
     if (!$path_service) {
         $path_service = $io->ask($this->trans('commands.generate.service.questions.path'), '/modules/custom/' . $module . '/src/');
         $input->setOption('path_service', $path_service);
     }
 }
开发者ID:jlbellido,项目名称:DrupalConsole,代码行数:45,代码来源:ServiceCommand.php

示例11: servicesQuestion

 /**
  * @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;
     }
 }
开发者ID:blasoliva,项目名称:DrupalConsole,代码行数:26,代码来源:ServicesTrait.php

示例12: breakpointQuestion

 /**
  * @param DrupalStyle $io
  *
  * @return mixed
  */
 public function breakpointQuestion(DrupalStyle $io)
 {
     $stringUtils = $this->getStringHelper();
     $validators = $this->getValidator();
     $breakpoints = [];
     while (true) {
         $breakPointName = $io->ask($this->trans('commands.generate.theme.questions.breakpoint-name'), 'narrow', function ($breakPointName) use($validators) {
             return $validators->validateMachineName($breakPointName);
         });
         $breakPointLabel = $stringUtils->createMachineName($breakPointName);
         $breakPointLabel = $io->ask($this->trans('commands.generate.theme.questions.breakpoint-label'), $breakPointLabel, function ($breakPointLabel) use($validators) {
             return $validators->validateMachineName($breakPointLabel);
         });
         $breakPointMediaQuery = $io->ask($this->trans('commands.generate.theme.questions.breakpoint-media-query'), 'all and (min-width: 560px) and (max-width: 850px)');
         $breakPointWeight = $io->ask($this->trans('commands.generate.theme.questions.breakpoint-weight'), '1');
         $breakPointMultipliers = $io->ask($this->trans('commands.generate.theme.questions.breakpoint-multipliers'), '1x');
         array_push($breakpoints, ['breakpoint_name' => $breakPointName, 'breakpoint_label' => $breakPointLabel, 'breakpoint_media_query' => $breakPointMediaQuery, 'breakpoint_weight' => $breakPointWeight, 'breakpoint_multipliers' => $breakPointMultipliers]);
         if (!$io->confirm($this->trans('commands.generate.theme.questions.breakpoint-add'), true)) {
             break;
         }
     }
     return $breakpoints;
 }
开发者ID:blasoliva,项目名称:DrupalConsole,代码行数:28,代码来源:ThemeBreakpointTrait.php

示例13: interact

 /**
  * {@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);
     }
     // --class option
     $className = $input->getOption('class');
     if (!$className) {
         $className = $io->ask($this->trans('commands.generate.form.questions.class'), 'DefaultForm');
         $input->setOption('class', $className);
     }
     // --form-id option
     $formId = $input->getOption('form-id');
     if (!$formId) {
         $formId = $io->ask($this->trans('commands.generate.form.questions.form-id'), $this->getStringHelper()->camelCaseToMachineName($className));
         $input->setOption('form-id', $formId);
     }
     // --services option
     // @see use Drupal\Console\Command\ServicesTrait::servicesQuestion
     $services = $this->servicesQuestion($output);
     $input->setOption('services', $services);
     // --inputs option
     $inputs = $input->getOption('inputs');
     if (!$inputs) {
         // @see \Drupal\Console\Command\FormTrait::formQuestion
         $inputs = $this->formQuestion($output);
         $input->setOption('inputs', $inputs);
     }
     // --routing option for ConfigFormBase
     if ($this->formType == 'ConfigFormBase') {
         $routing = $input->getOption('routing');
         if (!$routing) {
             $routing = $io->confirm($this->trans('commands.generate.form.questions.routing'), true);
             $input->setOption('routing', $routing);
         }
     }
     // --link option for links.menu
     if ($this->formType == 'ConfigFormBase') {
         $menu_options = $this->menuQuestion($output, $className);
         $menu_link_gen = $input->getOption('menu_link_gen');
         $menu_link_title = $input->getOption('menu_link_title');
         $menu_parent = $input->getOption('menu_parent');
         $menu_link_desc = $input->getOption('menu_link_desc');
         if (!$menu_link_gen || !$menu_link_title || !$menu_parent || !$menu_link_desc) {
             $input->setOption('menu_link_gen', $menu_options['menu_link_gen']);
             $input->setOption('menu_link_title', $menu_options['menu_link_title']);
             $input->setOption('menu_parent', $menu_options['menu_parent']);
             $input->setOption('menu_link_desc', $menu_options['menu_link_desc']);
         }
     }
 }
开发者ID:blasoliva,项目名称:DrupalConsole,代码行数:59,代码来源:FormCommand.php

示例14: interact

 /**
  * {@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);
         }
     }
 }
开发者ID:naveenvalecha,项目名称:DrupalConsole,代码行数:27,代码来源:ExportSingleCommand.php

示例15: interact

 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $utils = $this->getStringHelper();
     // --module option
     $module = $input->getOption('module');
     if (!$module) {
         // @see Drupal\Console\Command\ModuleTrait::moduleQuestion
         $module = $this->moduleQuestion($output);
         $input->setOption('module', $module);
     }
     // --class option
     $className = $input->getOption('class');
     if (!$className) {
         $className = $io->ask($this->trans('commands.generate.controller.questions.class'), 'DefaultController', function ($className) {
             return $this->validateClassName($className);
         });
         $input->setOption('class', $className);
     }
     $routes = [];
     while (true) {
         // --title option
         $title = $input->getOption('title');
         if (!$title) {
             $title = $io->ask($this->trans('commands.generate.controller.questions.title'), $utils->camelCaseToHuman($className), function ($title) use($routes) {
                 if (!empty($routes) && empty($title)) {
                     return false;
                 }
                 if (in_array($title, array_column($routes, 'title'))) {
                     throw new \InvalidArgumentException(sprintf($this->trans('commands.generate.controller.messages.title-already-added'), $title));
                 }
                 return $title;
             });
         }
         if ($title === false) {
             break;
         }
         // --method option
         $method = $input->getOption('method');
         if (!$method) {
             $method = $io->ask($this->trans('commands.generate.controller.questions.method'), 'index', function ($method) use($routes) {
                 if (in_array($method, array_column($routes, 'method'))) {
                     throw new \InvalidArgumentException(sprintf($this->trans('commands.generate.controller.messages.method-already-added'), $method));
                 }
                 return $method;
             });
         }
         // --route option option
         $route = $input->getOption('route');
         if (!$route) {
             $route = $io->ask($this->trans('commands.generate.controller.questions.route'), sprintf('%s/%s/hello/{name}', $module, $method), function ($route) use($routes) {
                 if (in_array($route, array_column($routes, 'route'))) {
                     throw new \InvalidArgumentException(sprintf($this->trans('commands.generate.controller.messages.route-already-added'), $route));
                 }
                 return $route;
             });
         }
         $routes[] = ['title' => $title, 'method' => $method, 'route' => $route];
         if (!$output->confirm($this->trans('commands.generate.controller.questions.controller-add'), true)) {
             break;
         }
     }
     $input->setOption('title', array_column($routes, 'title'));
     $input->setOption('method', array_column($routes, 'method'));
     $input->setOption('route', array_column($routes, 'route'));
     // --test option
     $test = $input->getOption('test');
     if (!$test) {
         $test = $io->confirm($this->trans('commands.generate.controller.questions.test'), true);
         $input->setOption('test', $test);
     }
     // --services option
     // @see use Drupal\Console\Command\ServicesTrait::servicesQuestion
     $services = $this->servicesQuestion($output);
     $input->setOption('services', $services);
 }
开发者ID:gapple,项目名称:DrupalConsole,代码行数:79,代码来源:ControllerCommand.php


注:本文中的Drupal\Console\Style\DrupalStyle::confirm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。