Example #1
0
 /**
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     /** @var DialogHelper $dialog */
     $dialog = $this->getHelper('dialog');
     $username = $dialog->askAndValidate($output, 'Please give the email:', function ($username) {
         if (empty($username)) {
             throw new \Exception('email can not be empty');
         }
         return $username;
     });
     $this->addArgument('email');
     $input->setArgument('email', $username);
     $password = $dialog->askHiddenResponseAndValidate($output, 'Please enter the new password:', function ($password) {
         if (empty($password)) {
             throw new \Exception('Password can not be empty');
         }
         return $password;
     });
     $this->addArgument('password');
     $input->setArgument('password', $password);
     $name = $dialog->askAndValidate($output, 'Please give the name:', function ($name) {
         if (empty($name)) {
             throw new \Exception('Name can not be empty');
         }
         return $name;
     });
     $this->addArgument('name');
     $input->setArgument('name', $name);
 }
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $output = new DrupalStyle($input, $output);
     $user = $input->getArgument('user');
     if (!$user) {
         $user = $output->ask($this->trans('commands.user.password.reset.questions.user'), '', function ($uid) {
             $uid = (int) $uid;
             if (is_int($uid) && $uid > 0) {
                 return $uid;
             } else {
                 throw new \InvalidArgumentException(sprintf($this->trans('commands.user.password.reset.questions.invalid-uid'), $uid));
             }
         });
         $input->setArgument('user', $user);
     }
     $password = $input->getArgument('password');
     if (!$password) {
         $password = $output->ask($this->trans('commands.user.password.hash.questions.password'), '', function ($pass) {
             if (!empty($pass)) {
                 return $pass;
             } else {
                 throw new \InvalidArgumentException(sprintf($this->trans('commands.user.password.hash.questions.invalid-pass'), $pass));
             }
         });
         $input->setArgument('password', $password);
     }
 }
Example #3
0
 /**
  * {@inheritDoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     //game type
     $input->setArgument(self::ARGUMENT_GAME_TYPE, $this->getGameType($output));
     //amount of players
     $input->setArgument(self::ARGUMENT_GAME_PLAYERS, $this->addPlayers($output));
 }
Example #4
0
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     /** @var StorageInterface $storage */
     $storage = $this->getContainer()->get('storage');
     $files = $input->getArgument('files');
     if ($input->getOption('latest')) {
         $remoteFiles = $storage->remoteListing();
         if (count($remoteFiles) > 0) {
             $files[] = end($remoteFiles);
             $input->setArgument('files', $files);
         }
     }
     if ($input->hasArgument('files') && !empty($files)) {
         return;
     }
     $remoteFiles = $storage->remoteListing();
     $localFiles = $storage->localListing();
     if (count(array_diff($remoteFiles, $localFiles)) === 0) {
         $output->writeln('All files fetched');
         return;
     }
     $helper = $this->getHelper('question');
     $question = new ChoiceQuestion('Which backup', array_values(array_diff($remoteFiles, $localFiles)));
     $question->setMultiselect(true);
     $question->setErrorMessage('Backup %s is invalid.');
     $question->setAutocompleterValues([]);
     $input->setArgument('files', $helper->ask($input, $output, $question));
 }
Example #5
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);
     }
 }
Example #6
0
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     $input->setArgument('from', $this->fs->toAbsolutePath($input->getArgument('from')));
     $this->fs->validateExists($input->getArgument('from'));
     $input->setArgument('to', $this->fs->toAbsolutePath($input->getArgument('to')));
     $this->fs->validateExists($input->getArgument('to'));
 }
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     if (!$input->getArgument('email')) {
         $email = $this->getHelper('dialog')->askAndValidate($output, 'Please enter an email:', function ($username) {
             if (empty($username)) {
                 throw new \Exception('Email can not be empty');
             }
             return $username;
         });
         $input->setArgument('email', $email);
     }
     if (!$input->getArgument('password')) {
         $password = $this->getHelper('dialog')->askHiddenResponseAndValidate($output, 'Please choose a password:', function ($password) {
             if (empty($password)) {
                 throw new \Exception('Password can not be empty');
             }
             return $password;
         });
         $input->setArgument('password', $password);
     }
     if (!$input->getArgument('roles')) {
         $roles = $this->getHelper('dialog')->ask($output, 'Please enter user\'s roles (separated by space):');
         if (!empty($roles)) {
             $input->setArgument('roles', explode(' ', $roles));
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $dialog = $this->getDialogHelper();
     $user = $input->getArgument('user');
     if (!$user) {
         $user = $dialog->askAndValidate($output, $dialog->getQuestion($this->trans('commands.user.password.reset.questions.user'), ''), function ($uid) {
             $uid = (int) $uid;
             if (is_int($uid) && $uid > 0) {
                 return $uid;
             } else {
                 throw new \InvalidArgumentException(sprintf($this->trans('commands.user.password.reset.questions.invalid-uid'), $uid));
             }
         }, false, '', null);
     }
     $input->setArgument('user', $user);
     $password = $input->getArgument('password');
     if (!$password) {
         $password = $dialog->askAndValidate($output, $dialog->getQuestion($this->trans('commands.user.password.hash.questions.password'), ''), function ($pass) {
             if (!empty($pass)) {
                 return $pass;
             } else {
                 throw new \InvalidArgumentException(sprintf($this->trans('commands.user.password.hash.questions.invalid-pass'), $pass));
             }
         }, false, '', null);
     }
     $input->setArgument('password', $password);
 }
 public function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $bundle = $input->getArgument('bundle');
     $name = $input->getArgument('name');
     $container = $this->getContainer();
     if (null !== $bundle && null !== $name) {
         return;
     }
     $io->title('Generate new RPC method');
     // Bundle name
     $bundle = $io->ask('Bundle name', null, function ($answer) use($container) {
         try {
             $container->get('kernel')->getBundle($answer);
         } catch (\Exception $e) {
             throw new \RuntimeException(sprintf('Bundle "%s" does not exist.', $answer));
         }
         return $answer;
     });
     $input->setArgument('bundle', $bundle);
     // Method name
     $name = $io->ask('Method name', null, function ($answer) use($container, $bundle) {
         if (empty($answer)) {
             throw new \RuntimeException('Method name can`t be empty.');
         }
         $answer = str_replace(' ', ':', $answer);
         if ($this->isMethodExist($container->get('kernel')->getBundle($bundle), $answer)) {
             throw new \RuntimeException(sprintf('Method "%s" already exist.', $answer));
         }
         return $answer;
     });
     $input->setArgument('name', $name);
 }
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $output->writeln($this->app['app.signature']);
     $output->writeln(array('', ' Welcome to the ShakeTheNations interactive cli-tool', ''));
     $dialog = $this->getHelperSet()->get('dialog');
     $location = $input->getArgument('location') ?: $dialog->askAndValidate($output, "Please, type your <info>location</info>" . " (e.g. <comment>Nantes, France</comment>)" . "\n > ", function ($location) use($input) {
         $input->setArgument('location', $location);
     });
     $distance = $input->getArgument('distance') ?: $dialog->askAndValidate($output, "Please, type the max <info>distance</info> (kilometers)" . " (e.g. <comment>500</comment>)" . "\n > ", function ($distance) use($input) {
         $input->setArgument('distance', $distance);
     });
 }
Example #11
0
 /**
  * Adds form console fields customizing the field name and its validation method.
  *
  * @param string $name   The field name
  * @param string $method The method that be executed
  *
  * @return $this self
  */
 private function addField($name, $method = 'askAndValidate')
 {
     if (!$this->input->getArgument($name)) {
         $field = $this->getHelper('dialog')->{$method}($this->output, sprintf('Please choose a/an %s:', $name), function ($field) {
             if (empty($field)) {
                 throw new \Exception('This field can not be empty');
             }
             return $field;
         });
         $this->input->setArgument($name, $field);
     }
     return $this;
 }
Example #12
0
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $directory = $input->getArgument('directory');
     if (!$directory) {
         $directory = $io->ask($this->trans('commands.site.new.questions.directory'));
         $input->setArgument('directory', $directory);
     }
     $version = $input->getArgument('version');
     if (!$version) {
         $version = $this->releasesQuestion($io, 'drupal');
         $input->setArgument('version', $version);
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $directory = $input->getArgument('directory');
     if (!$directory) {
         $directory = $io->ask($this->trans('commands.site.import.local.questions.directory'), getcwd());
         $input->setArgument('directory', $directory);
     }
     $name = $input->getArgument('name');
     if (!$name) {
         $name = $io->ask($this->trans('commands.site.import.local.questions.name'));
         $input->setArgument('name', $name);
     }
 }
Example #14
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);
     }
 }
 /**
  * Handle the command.
  *
  * @param AddonCollection $addons
  */
 public function handle()
 {
     if (!($addon = $this->input->getOption('addon'))) {
         return;
     }
     if (!($addon = $this->dispatch(new GetAddon($addon)))) {
         throw new \Exception("Addon could not be found.");
     }
     $this->input->setArgument('name', $addon->getNamespace() . '__' . $this->input->getArgument('name'));
     $this->input->setOption('path', $addon->getAppPath('migrations'));
     if (!is_dir($directory = $addon->getPath('migrations'))) {
         mkdir($directory);
     }
 }
 /**
  * {@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);
     }
 }
 /**
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  */
 protected function askForArguments(InputInterface $input, OutputInterface $output)
 {
     $dialog = $this->getHelperSet()->get('dialog');
     // db-host
     if ($input->getArgument('db-host') === null) {
         $input->setArgument('db-host', $dialog->ask($output, '<question>Please enter the database host:</question>'));
     }
     if ($input->getArgument('db-host') === null) {
         $output->writeln('<error>db-host was not set.</error>');
         return;
     }
     // db-user
     if ($input->getArgument('db-user') === null) {
         $input->setArgument('db-user', $dialog->ask($output, '<question>Please enter the database username:</question>'));
     }
     if ($input->getArgument('db-user') === null) {
         $output->writeln('<error>db-user was not set.</error>');
         return;
     }
     // db-pass
     if ($input->getArgument('db-pass') === null) {
         $input->setArgument('db-pass', $dialog->ask($output, '<question>Please enter the database password:</question>'));
     }
     // db-name
     if ($input->getArgument('db-name') === null) {
         $input->setArgument('db-name', $dialog->ask($output, '<question>Please enter the database name:</question>'));
     }
     if ($input->getArgument('db-name') === null) {
         $output->writeln('<error>db-name was not set.</error>');
         return;
     }
     // session-save
     if ($input->getArgument('session-save') === null) {
         $input->setArgument('session-save', $dialog->ask($output, '<question>Please enter the session save:</question>', 'files'));
     }
     if ($input->getArgument('session-save') === null) {
         $output->writeln('<error>session-save was not set.</error>');
         return;
     }
     // admin-frontname
     if ($input->getArgument('admin-frontname') === null) {
         $input->setArgument('admin-frontname', $dialog->ask($output, '<question>Please enter the admin frontname:</question>', 'admin'));
     }
     if ($input->getArgument('admin-frontname') === null) {
         $output->writeln('<error>admin-frontname was not set.</error>');
         return;
     }
 }
Example #18
0
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $entityDefinitionID = $input->getArgument('entity-definition-id');
     $entityID = $input->getArgument('entity-id');
     if (!$entityDefinitionID) {
         $entityTypes = $this->entityTypeRepository->getEntityTypeLabels(true);
         $entityType = $io->choice($this->trans('commands.entity.delete.questions.entity-type'), array_keys($entityTypes));
         $entityDefinitionID = $io->choice($this->trans('commands.entity.delete.questions.entity-definition-id'), array_keys($entityTypes[$entityType]));
         $input->setArgument('entity-definition-id', $entityDefinitionID);
     }
     if (!$entityID) {
         $entityID = $io->ask($this->trans('commands.entity.delete.questions.entity-id'));
         $input->setArgument('entity-id', $entityID);
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $uid = $input->getArgument('uid');
     // Check if $uid argument is already set.
     if (!$uid) {
         while (true) {
             // Request $uid argument.
             $uid = $io->ask($this->trans('commands.user.login.clear.attempts.questions.uid'), 1, function ($uid) use($io) {
                 $message = !is_numeric($uid) ? $this->trans('commands.user.login.clear.attempts.questions.numeric-uid') : false;
                 // Check if $uid is upper than zero.
                 if (!$message && $uid <= 0) {
                     $message = $this->trans('commands.user.login.clear.attempts.questions.invalid-uid');
                 }
                 // Check if message was defined.
                 if ($message) {
                     $io->error($message);
                     return false;
                 }
                 // Return a valid $uid.
                 return (int) $uid;
             });
             if ($uid) {
                 break;
             }
         }
         $input->setArgument('uid', $uid);
     }
 }
Example #20
0
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $rids = $input->getArgument('roles');
     if (!$rids) {
         $roles = $this->drupalApi->getRoles();
         $rids = $io->choice($this->trans('commands.create.users.questions.roles'), array_values($roles), null, true);
         $rids = array_map(function ($role) use($roles) {
             return array_search($role, $roles);
         }, $rids);
         $input->setArgument('roles', $rids);
     }
     $limit = $input->getOption('limit');
     if (!$limit) {
         $limit = $io->ask($this->trans('commands.create.users.questions.limit'), 10);
         $input->setOption('limit', $limit);
     }
     $password = $input->getOption('password');
     if (!$password) {
         $password = $io->ask($this->trans('commands.create.users.questions.password'), 5);
         $input->setOption('password', $password);
     }
     $timeRange = $input->getOption('time-range');
     if (!$timeRange) {
         $timeRanges = $this->getTimeRange();
         $timeRange = $io->choice($this->trans('commands.create.nodes.questions.time-range'), array_values($timeRanges));
         $input->setOption('time-range', array_search($timeRange, $timeRanges));
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $passwords = $input->getArgument('password');
     if (!$passwords) {
         $passwords = [];
         while (true) {
             $password = $io->ask($this->trans('commands.user.password.hash.questions.password'), '', function ($pass) use($passwords, $io) {
                 if (!empty($pass) || count($passwords) >= 1) {
                     if ($pass == '') {
                         return true;
                     }
                     return $pass;
                 } else {
                     $io->error(sprintf($this->trans('commands.user.password.hash.questions.invalid-pass'), $pass));
                     return false;
                 }
             });
             if ($password && !is_string($password)) {
                 break;
             }
             if (is_string($password)) {
                 $passwords[] = $password;
             }
         }
         $input->setArgument('password', $passwords);
     }
 }
Example #22
0
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $module = $input->getArgument('module');
     if (!$module) {
         $module_list = [];
         $dialog = $this->getDialogHelper();
         $modules = system_rebuild_module_data();
         foreach ($modules as $module_id => $module) {
             if ($module->status == 1) {
                 continue;
             }
             $module_list[$module_id] = $module->info['name'];
         }
         $output->writeln('[+] <info>' . $this->trans('commands.module.install.messages.disabled-modules') . '</info>');
         while (true) {
             $module_name = $dialog->askAndValidate($output, $dialog->getQuestion($this->trans('commands.module.install.questions.module'), ''), function ($module_id) use($module_list) {
                 if ($module_id == '' || $module_list[$module_id]) {
                     return $module_id;
                 } else {
                     throw new \InvalidArgumentException(sprintf($this->trans('commands.module.install.questions.invalid-module'), $module_id));
                 }
             }, false, '', array_keys($module_list));
             if (empty($module_name)) {
                 break;
             }
             $module_list_install[] = $module_name;
             if (array_search($module_name, $module_list_install, true) >= 0) {
                 unset($module_list[$module_name]);
             }
         }
         $input->setArgument('module', $module_list_install);
     }
     $overwrite_config = $input->getOption('overwrite-config');
     $input->setOption('overwrite-config', $overwrite_config);
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     # MVC object
     $mvc = MVCStore::retrieve('mvc');
     if ($input->getArgument('folder') == 'web') {
         $input->setArgument('folder', dirname($mvc->getAppDir()) . '/web');
     }
     $folderArg = rtrim($input->getArgument('folder'), '/');
     if (!is_dir($folderArg)) {
         throw new \InvalidArgumentException(sprintf('The target directory "%s" does not exist.', $input->getArgument('folder')));
     }
     $modulesPath = $folderArg . '/modules/';
     @mkdir($modulesPath);
     if ($input->getOption('symlinks')) {
         $output->writeln('Trying to install assets as <comment>symbolic links</comment>.');
     } else {
         $output->writeln('Installing assets as <comment>hard copies</comment>.');
     }
     foreach ($mvc->getModules() as $module) {
         if (is_dir($originDir = $module->getPath() . '/Resources/public')) {
             $targetDir = $modulesPath . preg_replace('/module$/', '', strtolower($module->getName()));
             $output->writeln(sprintf('Installing assets for <comment>%s</comment> into <comment>%s</comment>', $module->getNamespace(), $targetDir));
             if (!$this->recursiveRemoveDir($targetDir)) {
                 $output->writeln(sprintf('Could\'t been removed the dir "%s".', $targetDir));
             }
             if ($input->getOption('symlinks')) {
                 #link($originDir, $targetDir);
                 @symlink($originDir, $targetDir);
             } else {
                 $this->resourceCopy($originDir, $targetDir);
             }
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $output = 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);
     }
     // view-id argument
     $viewId = $input->getArgument('view-id');
     if (!$viewId) {
         $entityManager = $this->getEntityManager();
         $views = $entityManager->getStorage('view')->loadMultiple();
         $viewList = [];
         foreach ($views as $view) {
             $viewList[$view->get('id')] = $view->get('label');
         }
         $viewId = $output->choiceNoList($this->trans('commands.views.export.questions.view'), $viewList);
         $input->setArgument('view-id', $viewId);
     }
     $optionalConfig = $input->getOption('optional-config');
     if (!$optionalConfig) {
         $optionalConfig = $output->confirm($this->trans('commands.config.export.view.questions.optional-config'), true);
         $input->setOption('optional-config', $optionalConfig);
     }
     $includeModuleDependencies = $input->getOption('include-module-dependencies');
     if (!$includeModuleDependencies) {
         $includeModuleDependencies = $output->confirm($this->trans('commands.config.export.view.questions.include-module-dependencies'), true);
         $input->setOption('include-module-dependencies', $includeModuleDependencies);
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $nodeId = $input->getArgument('node-id');
     if (!$nodeId) {
         $nodeId = $io->ask($this->trans('commands.create.comments.questions.node-id'));
         $input->setArgument('node-id', $nodeId);
     }
     $limit = $input->getOption('limit');
     if (!$limit) {
         $limit = $io->ask($this->trans('commands.create.comments.questions.limit'), 25);
         $input->setOption('limit', $limit);
     }
     $titleWords = $input->getOption('title-words');
     if (!$titleWords) {
         $titleWords = $io->ask($this->trans('commands.create.comments.questions.title-words'), 5);
         $input->setOption('title-words', $titleWords);
     }
     $timeRange = $input->getOption('time-range');
     if (!$timeRange) {
         $timeRanges = $this->getTimeRange();
         $timeRange = $io->choice($this->trans('commands.create.comments.questions.time-range'), array_values($timeRanges));
         $input->setOption('time-range', array_search($timeRange, $timeRanges));
     }
 }
 /**
  * {@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);
     }
 }
Example #27
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);
     }
 }
 /**
  * Execute command, adjust constraints and start update
  *
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = $this->getIO();
     $io->writeError('> ichhabrecht/composer-git-flow-plugin');
     $this->stability = $input->getOption('stability');
     $stability = trim((string) getenv('STABILITY'));
     if (!empty($stability)) {
         $io->writeError('Warning: You are using the deprecated environment variable `STABILITY`. Please use cli option --stability ' . $stability);
         $this->stability = $stability;
     }
     $io->writeError('  - using STABILITY=' . $this->stability);
     $io->writeError('');
     $composer = $this->getComposer(true, $input->getOption('no-plugins'));
     $requires = $composer->getPackage()->getRequires();
     $newRequires = $this->adjustGitFlowPackages($requires);
     $packages = array_keys($newRequires);
     $composer->getPackage()->setRequires(array_merge($requires, $newRequires));
     if (!$input->getOption('no-dev')) {
         $requires = $this->adjustGitFlowPackages($composer->getPackage()->getDevRequires());
         $newRequires = $this->adjustGitFlowPackages($requires);
         $packages += array_keys($newRequires);
         $composer->getPackage()->setDevRequires(array_merge($requires, $newRequires));
     }
     $input->setArgument('packages', $packages);
     $io->writeError('');
     return parent::execute($input, $output);
 }
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $dialog = $this->getDialogHelper();
     // --module option
     $module = $input->getOption('module');
     if (!$module) {
         // @see Drupal\Console\Command\ModuleTrait::moduleQuestion
         $module = $this->moduleQuestion($output, $dialog);
     }
     $input->setOption('module', $module);
     // --content type argument
     $content_type = $input->getArgument('content_type');
     if (!$content_type) {
         $entity_manager = $this->getEntityManager();
         $bundles_entities = $entity_manager->getStorage('node_type')->loadMultiple();
         $bundles = array();
         foreach ($bundles_entities as $entity) {
             $bundles[$entity->id()] = $entity->label();
         }
         $content_type = $dialog->askAndValidate($output, $dialog->getQuestion($this->trans('commands.config.export.content.type.questions.content_type'), ''), function ($bundle) use($bundles) {
             if (!in_array($bundle, array_values($bundles))) {
                 throw new \InvalidArgumentException(sprintf('Content type "%s" is invalid.', $bundle));
             }
             return array_search($bundle, $bundles);
         }, false, '', $bundles);
     }
     $input->setArgument('content_type', $content_type);
 }
 /**
  * {@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($io);
     }
     $input->setOption('module', $module);
     // --content-type argument
     $contentType = $input->getArgument('content-type');
     if (!$contentType) {
         $entityTypeManager = $this->getService('entity_type.manager');
         $bundles_entities = $entityTypeManager->getStorage('node_type')->loadMultiple();
         $bundles = array();
         foreach ($bundles_entities as $entity) {
             $bundles[$entity->id()] = $entity->label();
         }
         $contentType = $io->choice($this->trans('commands.config.export.content.type.questions.content-type'), $bundles);
     }
     $input->setArgument('content-type', $contentType);
     $optionalConfig = $input->getOption('optional-config');
     if (!$optionalConfig) {
         $optionalConfig = $io->confirm($this->trans('commands.config.export.content.type.questions.optional-config'), true);
     }
     $input->setOption('optional-config', $optionalConfig);
 }