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


PHP DrupalStyle::askEmpty方法代码示例

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


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

示例1: interact

 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.fieldtype.questions.class'), 'ExampleFieldType');
         $input->setOption('class', $class_name);
     }
     // --label option
     $label = $input->getOption('label');
     if (!$label) {
         $label = $io->ask($this->trans('commands.generate.plugin.fieldtype.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.fieldtype.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.fieldtype.questions.description'), 'My Field Type');
         $input->setOption('description', $description);
     }
     // --default-widget option
     $default_widget = $input->getOption('default-widget');
     if (!$default_widget) {
         $default_widget = $io->askEmpty($this->trans('commands.generate.plugin.fieldtype.questions.default-widget'));
         $input->setOption('default-widget', $default_widget);
     }
     // --default-formatter option
     $default_formatter = $input->getOption('default-formatter');
     if (!$default_formatter) {
         $default_formatter = $io->askEmpty($this->trans('commands.generate.plugin.fieldtype.questions.default-formatter'));
         $input->setOption('default-formatter', $default_formatter);
     }
 }
开发者ID:mnico,项目名称:DrupalConsole,代码行数:47,代码来源:PluginFieldTypeCommand.php

示例2: interact

 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $userId = $input->getOption('user-id');
     if (!$userId) {
         $userId = $io->askEmpty($this->trans('commands.user.delete.questions.user-id'), null);
         $input->setOption('user-id', $userId);
     }
     $roles = $input->getOption('roles');
     if (!$userId && !$roles) {
         $systemRoles = $this->drupalApi->getRoles(false, false, false);
         $roles = $io->choice($this->trans('commands.user.delete.questions.roles'), array_values($systemRoles), null, true);
         $roles = array_map(function ($role) use($systemRoles) {
             return array_search($role, $systemRoles);
         }, $roles);
         $input->setOption('roles', $roles);
     }
 }
开发者ID:ranqiangjun,项目名称:DrupalConsole,代码行数:21,代码来源:DeleteCommand.php

示例3: 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
     $class = $input->getOption('class');
     if (!$class) {
         $class = $io->ask($this->trans('commands.generate.controller.questions.class'), 'DefaultController', function ($class) {
             return $this->validateClassName($class);
         });
         $input->setOption('class', $class);
     }
     $routes = $input->getOption('routes');
     if (!$routes) {
         while (true) {
             $title = $io->askEmpty($this->trans('commands.generate.controller.questions.title'), function ($title) use($routes) {
                 if ($routes && empty(trim($title))) {
                     return false;
                 }
                 if (!$routes && empty(trim($title))) {
                     throw new \InvalidArgumentException($this->trans('commands.generate.controller.messages.title-empty'));
                 }
                 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 === '') {
                 break;
             }
             $method = $io->ask($this->trans('commands.generate.controller.questions.method'), 'hello', 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;
             });
             $path = $io->ask($this->trans('commands.generate.controller.questions.path'), sprintf('/%s/hello/{name}', $module), function ($path) use($routes) {
                 if (in_array($path, array_column($routes, 'path'))) {
                     throw new \InvalidArgumentException(sprintf($this->trans('commands.generate.controller.messages.path-already-added'), $path));
                 }
                 return $path;
             });
             $routes[] = ['title' => $title, 'method' => $method, 'path' => $path];
         }
         $input->setOption('routes', $routes);
     }
     // --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:durgeshs,项目名称:DrupalConsole,代码行数:66,代码来源:ControllerCommand.php

示例4: dbPrefixQuestion

 /**
  * @param DrupalStyle $output
  *
  * @return mixed
  */
 public function dbPrefixQuestion(DrupalStyle $output)
 {
     return $output->askEmpty($this->trans('commands.migrate.execute.questions.db-prefix'));
 }
开发者ID:ostark,项目名称:DrupalConsole,代码行数:9,代码来源:DatabaseTrait.php

示例5: formQuestion

 /**
  * @param DrupalStyle $output
  *
  * @return mixed
  */
 public function formQuestion(DrupalStyle $output)
 {
     if ($output->confirm($this->trans('commands.common.questions.inputs.confirm'), true)) {
         $input_types = ['fieldset'];
         $elementInfoManager = $this->hasGetService('plugin.manager.element_info');
         if (!$elementInfoManager) {
             return false;
         }
         foreach ($elementInfoManager->getDefinitions() as $definition) {
             $type = $definition['id'];
             $elementInfo = $elementInfoManager->getInfo($type);
             if (isset($elementInfo['#input']) && $elementInfo['#input']) {
                 if (!in_array($type, $input_types)) {
                     $input_types[] = $type;
                 }
             }
         }
         sort($input_types);
         $inputs = [];
         $fieldSets = [];
         while (true) {
             $input_type = $output->choiceNoList($this->trans('commands.common.questions.inputs.type'), $input_types, null, true);
             if (empty($input_type)) {
                 break;
             }
             // Label for input
             $inputLabelMessage = $input_type == 'fieldset' ? $this->trans('commands.common.questions.inputs.title') : $this->trans('commands.common.questions.inputs.label');
             $input_label = $output->ask($inputLabelMessage, null);
             // Machine name
             $input_machine_name = $this->getStringHelper()->createMachineName($input_label);
             $input_name = $output->ask($this->trans('commands.common.questions.inputs.machine_name'), $input_machine_name);
             if ($input_type == 'fieldset') {
                 $fieldSets[$input_machine_name] = $input_label;
             }
             $inputFieldSet = '';
             if ($input_type != 'fieldset' && !empty($fieldSets)) {
                 $inputFieldSet = $output->choiceNoList($this->trans('commands.common.questions.inputs.fieldset'), $fieldSets, null, true);
                 $inputFieldSet = array_search($inputFieldSet, $fieldSets);
             }
             $maxlength = null;
             $size = null;
             if (in_array($input_type, array('textfield', 'password', 'password_confirm'))) {
                 $maxlength = $output->ask('Maximum amount of characters', '64');
                 $size = $output->ask('Width of the textfield (in characters)', '64');
             }
             if ($input_type == 'select') {
                 $size = $output->askEmpty('Size of multiselect box (in lines)', '5');
             }
             $input_options = '';
             if (in_array($input_type, array('checkboxes', 'radios', 'select'))) {
                 $input_options = $output->ask('Input options separated by comma');
             }
             // Prepare options as an array
             if (strlen(trim($input_options))) {
                 // remove spaces in options and empty options
                 $input_options = array_filter(array_map('trim', explode(',', $input_options)));
                 // Create array format for options
                 foreach ($input_options as $key => $value) {
                     $input_options_output[$key] = "'{$value}' => \$this->t('" . $value . "')";
                 }
                 $input_options = 'array(' . implode(', ', $input_options_output) . ')';
             }
             // Description for input
             $input_description = $output->askEmpty($this->trans('commands.common.questions.inputs.description'));
             if ($input_type != 'fieldset') {
                 // Default value for input
                 $default_value = $output->askEmpty($this->trans('commands.common.questions.inputs.default-value'));
             }
             // Weight for input
             $weight = $output->ask($this->trans('commands.common.questions.inputs.weight'), '0');
             array_push($inputs, ['name' => $input_name, 'type' => $input_type, 'label' => $input_label, 'options' => $input_options, 'description' => $input_description, 'maxlength' => $maxlength, 'size' => $size, 'default_value' => $default_value, 'weight' => $weight, 'fieldset' => $inputFieldSet]);
         }
         return $inputs;
     }
     return null;
 }
开发者ID:eleaga,项目名称:DrupalConsole,代码行数:81,代码来源:FormTrait.php

示例6: interact

 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);
     }
     // --type-class option
     $typeClass = $input->getOption('type-class');
     if (!$typeClass) {
         $typeClass = $io->ask($this->trans('commands.generate.plugin.field.questions.type-class'), 'ExampleFieldType');
         $input->setOption('type-class', $typeClass);
     }
     // --type-label option
     $label = $input->getOption('type-label');
     if (!$label) {
         $label = $io->ask($this->trans('commands.generate.plugin.field.questions.type-label'), $this->getStringHelper()->camelCaseToHuman($typeClass));
         $input->setOption('type-label', $label);
     }
     // --type-plugin-id option
     $plugin_id = $input->getOption('type-plugin-id');
     if (!$plugin_id) {
         $plugin_id = $io->ask($this->trans('commands.generate.plugin.field.questions.type-plugin-id'), $this->getStringHelper()->camelCaseToUnderscore($typeClass));
         $input->setOption('type-plugin-id', $plugin_id);
     }
     // --type-description option
     $description = $input->getOption('type-description');
     if (!$description) {
         $description = $io->ask($this->trans('commands.generate.plugin.field.questions.type-description'), 'My Field Type');
         $input->setOption('type-description', $description);
     }
     // --widget-class option
     $widgetClass = $input->getOption('widget-class');
     if (!$widgetClass) {
         $widgetClass = $io->ask($this->trans('commands.generate.plugin.field.questions.widget-class'), 'ExampleWidgetType');
         $input->setOption('widget-class', $widgetClass);
     }
     // --widget-label option
     $widgetLabel = $input->getOption('widget-label');
     if (!$widgetLabel) {
         $widgetLabel = $io->ask($this->trans('commands.generate.plugin.field.questions.widget-label'), $this->getStringHelper()->camelCaseToHuman($widgetClass));
         $input->setOption('widget-label', $widgetLabel);
     }
     // --widget-plugin-id option
     $widget_plugin_id = $input->getOption('widget-plugin-id');
     if (!$widget_plugin_id) {
         $widget_plugin_id = $io->ask($this->trans('commands.generate.plugin.field.questions.widget-plugin-id'), $this->getStringHelper()->camelCaseToUnderscore($widgetClass));
         $input->setOption('widget-plugin-id', $widget_plugin_id);
     }
     // --formatter-class option
     $formatterClass = $input->getOption('formatter-class');
     if (!$formatterClass) {
         $formatterClass = $io->ask($this->trans('commands.generate.plugin.field.questions.formatter-class'), 'ExampleFormatterType');
         $input->setOption('formatter-class', $formatterClass);
     }
     // --formatter-label option
     $formatterLabel = $input->getOption('formatter-label');
     if (!$formatterLabel) {
         $formatterLabel = $io->ask($this->trans('commands.generate.plugin.field.questions.formatter-label'), $this->getStringHelper()->camelCaseToHuman($widgetClass));
         $input->setOption('formatter-label', $formatterLabel);
     }
     // --formatter-plugin-id option
     $formatter_plugin_id = $input->getOption('formatter-plugin-id');
     if (!$formatter_plugin_id) {
         $formatter_plugin_id = $io->ask($this->trans('commands.generate.plugin.field.questions.formatter-plugin-id'), $this->getStringHelper()->camelCaseToUnderscore($widgetClass));
         $input->setOption('formatter-plugin-id', $formatter_plugin_id);
     }
     // --field-type option
     $field_type = $input->getOption('field-type');
     if (!$field_type) {
         $field_type = $io->ask($this->trans('commands.generate.plugin.field.questions.field-type'), $plugin_id);
         $input->setOption('field-type', $field_type);
     }
     // --default-widget option
     $default_widget = $input->getOption('default-widget');
     if (!$default_widget) {
         $default_widget = $io->askEmpty($this->trans('commands.generate.plugin.field.questions.default-widget'), $widget_plugin_id);
         $input->setOption('default-widget', $default_widget);
     }
     // --default-formatter option
     $default_formatter = $input->getOption('default-formatter');
     if (!$default_formatter) {
         $default_formatter = $io->askEmpty($this->trans('commands.generate.plugin.field.questions.default-formatter'), $formatter_plugin_id);
         $input->setOption('default-formatter', $default_formatter);
     }
 }
开发者ID:blasoliva,项目名称:DrupalConsole,代码行数:89,代码来源:PluginFieldCommand.php

示例7: interact

 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $username = $input->getArgument('username');
     while (!$username) {
         $username = $io->askEmpty($this->trans('commands.user.create.questions.username'), null);
     }
     $input->setArgument('username', $username);
     $password = $input->getArgument('password');
     if (!$password) {
         $password = $io->askEmpty($this->trans('commands.user.create.questions.password'), null);
     }
     $input->setArgument('password', $password);
     $roles = $input->getOption('roles');
     if (!$roles) {
         $systemRoles = $this->drupalApi->getRoles(false, false, false);
         $roles = $io->choice($this->trans('commands.user.create.questions.roles'), array_values($systemRoles), null, true);
         $roles = array_map(function ($role) use($systemRoles) {
             return array_search($role, $systemRoles);
         }, $roles);
         $input->setOption('roles', $roles);
     }
     $email = $input->getOption('email');
     if (!$email) {
         $email = $io->askEmpty($this->trans('commands.user.create.questions.email'), null);
     }
     $input->setOption('email', $email);
     $status = $input->getOption('status');
     if (!$status) {
         $status = $io->choice($this->trans('commands.user.create.questions.status'), [0, 1], 1);
     }
     $input->setOption('status', $status);
 }
开发者ID:ranqiangjun,项目名称:DrupalConsole,代码行数:36,代码来源:CreateCommand.php


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