/** * {@inheritdoc} */ protected function interact(InputInterface $input, OutputInterface $output) { // --base_class option. // @todo Turn this into a choice() option. $base_class = $input->getOption('base_class'); if (empty($base_class)) { $base_class = $output->ask($this->trans('commands.generate.metatag.group.questions.base_class'), 'GroupBase'); } $input->setOption('base_class', $base_class); // --module option. $module = $input->getOption('module'); if (empty($module)) { // @see Drupal\AppConsole\Command\Helper\ModuleTrait::moduleQuestion $module = $this->moduleQuestion($output); } $input->setOption('module', $module); // --label option. $label = $input->getOption('label'); if (empty($label)) { $label = $output->ask($this->trans('commands.generate.metatag.group.questions.label')); } $input->setOption('label', $label); // --description option. $description = $input->getOption('description'); if (empty($description)) { $description = $output->ask($this->trans('commands.generate.metatag.group.questions.description')); } $input->setOption('description', $description); // --plugin-id option. $plugin_id = $input->getOption('plugin-id'); if (empty($plugin_id)) { $plugin_id = $output->ask($this->trans('commands.generate.metatag.group.questions.plugin_id')); } $input->setOption('plugin-id', $plugin_id); // --class-name option. $class_name = $input->getOption('class-name'); if (empty($class_name)) { $class_name = $output->ask($this->trans('commands.generate.metatag.group.questions.class_name')); } $input->setOption('class-name', $class_name); // --weight option. // @todo Automatically get the next integer value based upon the current // group. $weight = $input->getOption('weight'); if (is_null($weight)) { $weight = $output->ask($this->trans('commands.generate.metatag.group.questions.weight'), 0); } $input->setOption('weight', $weight); }
/** * {@inheritdoc} */ protected function interact(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $validator_filename = function ($value) use($io) { if (!strlen(trim($value)) || !is_file($value)) { $io->error($this->trans('commands.common.errors.invalid-file-path')); return false; } return $value; }; // --yaml-left option $yaml_left = $input->getArgument('yaml-left'); if (!$yaml_left) { while (true) { $yaml_left = $output->ask($this->trans('commands.yaml.diff.questions.yaml-left'), null, $validator_filename); if ($yaml_left) { break; } } $input->setArgument('yaml-left', $yaml_left); } // --yaml-right option $yaml_right = $input->getArgument('yaml-right'); if (!$yaml_right) { while (true) { $yaml_right = $output->ask($this->trans('commands.yaml.diff.questions.yaml-right'), null, $validator_filename); if ($yaml_right) { break; } } $input->setArgument('yaml-right', $yaml_right); } }
/** * {@inheritdoc} */ protected function interact(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $stringUtils = $this->getStringHelper(); $validators = $this->getValidator(); try { // A profile is technically also a module, so we can use the same // validator to check the name. $profile = $input->getOption('profile') ? $this->validateModuleName($input->getOption('profile')) : null; } catch (\Exception $error) { $io->error($error->getMessage()); return; } if (!$profile) { $profile = $io->ask($this->trans('commands.generate.profile.questions.profile'), '', function ($profile) use($validators) { return $validators->validateModuleName($profile); }); $input->setOption('profile', $profile); } try { $machine_name = $input->getOption('machine-name') ? $this->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.profile.questions.machine-name'), $stringUtils->createMachineName($profile), function ($machine_name) use($validators) { return $validators->validateMachineName($machine_name); }); $input->setOption('machine-name', $machine_name); } $description = $input->getOption('description'); if (!$description) { $description = $io->ask($this->trans('commands.generate.profile.questions.description'), 'My Useful Profile'); $input->setOption('description', $description); } $core = $input->getOption('core'); if (!$core) { $core = $io->ask($this->trans('commands.generate.profile.questions.core'), '8.x'); $input->setOption('core', $core); } $dependencies = $input->getOption('dependencies'); if (!$dependencies) { if ($io->confirm($this->trans('commands.generate.profile.questions.dependencies'), true)) { $dependencies = $output->ask($this->trans('commands.generate.profile.options.dependencies'), ''); } $input->setOption('dependencies', $dependencies); } $distribution = $input->getOption('distribution'); if (!$distribution) { if ($io->confirm($this->trans('commands.generate.profile.questions.distribution'), false)) { $distribution = $output->ask($this->trans('commands.generate.profile.options.distribution'), 'My Kick-ass Distribution'); $input->setOption('distribution', $distribution); } } }
/** * Kullanıcıya soru sorar * * @param string $question * @param string $default * @return string */ public function ask($question, $default = null) { return $this->output->ask($question, $default); }
/** * {@inheritdoc} */ protected function interact(InputInterface $input, OutputInterface $output) { $boolean_options = ['FALSE', 'TRUE']; // ToDo: Take this from typed data, so it can be extended? $type_options = ['integer', 'string', 'label', 'uri', 'image']; // --base_class option. // @todo Turn this into a choice() option. $base_class = $input->getOption('base_class'); if (empty($base_class)) { $base_class = $output->ask($this->trans('commands.generate.metatag.tag.questions.base_class'), 'MetaNameBase'); } $input->setOption('base_class', $base_class); // --module option. $module = $input->getOption('module'); if (empty($module)) { // @see Drupal\AppConsole\Command\Helper\ModuleTrait::moduleQuestion $module = $this->moduleQuestion($output); } $input->setOption('module', $module); // --name option. // @todo Add validation. $name = $input->getOption('name'); if (empty($name)) { $name = $output->ask($this->trans('commands.generate.metatag.tag.questions.name')); } $input->setOption('name', $name); // --label option. $label = $input->getOption('label'); if (empty($label)) { $label = $output->ask($this->trans('commands.generate.metatag.tag.questions.label'), $name); } $input->setOption('label', $label); // --description option. $description = $input->getOption('description'); if (empty($description)) { $description = $output->ask($this->trans('commands.generate.metatag.tag.questions.description')); } $input->setOption('description', $description); // --plugin-id option. $plugin_id = $input->getOption('plugin-id'); if (empty($plugin_id)) { $plugin_id = $this->nameToPluginId($name); $plugin_id = $output->ask($this->trans('commands.generate.metatag.tag.questions.plugin_id'), $plugin_id); } $input->setOption('plugin-id', $plugin_id); // --class-name option. $class_name = $input->getOption('class-name'); if (empty($class_name)) { $class_name = $this->nameToClassName($name); $class_name = $output->ask($this->trans('commands.generate.metatag.tag.questions.class_name'), $class_name); } $input->setOption('class-name', $class_name); // --group option. $group = $input->getOption('group'); if (empty($group)) { $groups = $this->getGroups(); $group = $output->choice($this->trans('commands.generate.metatag.tag.questions.group'), $groups); } $input->setOption('group', $group); // --weight option. // @todo Automatically get the next integer value based upon the current // group. $weight = $input->getOption('weight'); if (is_null($weight)) { $weight = $output->ask($this->trans('commands.generate.metatag.tag.questions.weight'), 0); } $input->setOption('weight', $weight); // --type option. // @todo Turn this into an option. $type = $input->getOption('type'); if (is_null($type)) { $type = $output->choice($this->trans('commands.generate.metatag.tag.questions.type'), $type_options, 0); } $input->setOption('type', $type); // --multiple option. $multiple = $input->getOption('multiple'); if (is_null($multiple)) { $multiple = $output->choice($this->trans('commands.generate.metatag.tag.questions.multiple'), $boolean_options, 0); } $input->setOption('multiple', $multiple); }