Author: Fabien Potencier (fabien@symfony.com)
Inheritance: extends Helper
Ejemplo n.º 1
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     # get the di container
     $project = $this->getApplication()->getProject();
     # verify if a output file name been passed
     if (($out_file_name = $input->getArgument('out')) === null) {
         $out_file_name = 'schema.xml';
     } else {
         $out_file_name = rtrim($out_file_name, '.xml') . '.xml';
     }
     # load the schema analyser
     $schema_analyser = $project->getSchemaAnalyser();
     #run the analyser
     $schema = $schema_analyser->analyse($project->getDatabase(), $project->getXMLEngineBuilder());
     # write the scheam file to the project folder (sources)
     $sources_io = $project->getSourceIO();
     $formatted_xml = $schema_analyser->format($schema->toXml());
     try {
         #Write config file to the project
         $sources_io->write($out_file_name, '', $formatted_xml, $overrite = false);
         $output->writeLn('<comment>++</comment> <info>sources/' . $out_file_name . '</info>');
     } catch (FileExistException $e) {
         #ask if they want to overrite
         $dialog = new DialogHelper();
         $answer = $dialog->askConfirmation($output, "<question>{$out_file_name} already exists do you want to Overrite? [y|n]</question>:", false);
         if ($answer) {
             #Write config file to the project
             $sources_io->write($out_file_name, '', $formatted_xml, $overrite = true);
             $output->writeLn('<comment>++</comment> <info>sources/' . $out_file_name . '</info>');
         }
     }
 }
Ejemplo n.º 2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->app = $this->getApplication();
     $dialog = new DialogHelper();
     $case = $input->getArgument('case');
     if (null == $case) {
         $case = $this->app->getCurrent();
         if ($case == null || $case == 0) {
             $case = $dialog->ask($output, 'Enter a case number: ');
         }
     }
     try {
         $bug = $this->app->fogbugz->search(array('q' => (int) $case, 'cols' => 'ixBug,sTitle,sStatus,sLatestTextSummary,' . 'sProject,sArea,sPersonAssignedTo,sStatus,' . 'sPriority,sCategory,dtOpened,dtResolved,' . 'dtClosed,dtLastUpdated,sFixFor,ixBugParent'));
     } catch (ApiError $e) {
         $output->writeln(sprintf("<error>%s</error>", $e->getMessage()), $this->app->outputFormat);
         exit(1);
     }
     if (0 == $bug->cases['count']) {
         $output->writeln(sprintf('<error>Unable to retrieve [%d]</error>', $case), $this->app->outputFormat);
         exit(1);
     }
     // extract the case to local vars and then include the template
     $data = FogBugzHelpers::responseToArray($bug->cases->case);
     $data['host'] = $this->app->fogbugz->url;
     if ($data['ixBugParent'] == 0) {
         $data['ixBugParent'] = '—';
     }
     $data['statusFormat'] = $this->app->statusStyle($data['sStatus']);
     $template = $this->app->twig->loadTemplate('info.twig');
     $view = $template->render($data);
     $output->write($view, false, $this->app->outputFormat);
 }
Ejemplo n.º 3
0
 public function askAuth()
 {
     $dialog = new DialogHelper();
     self::$user = $dialog->ask($this->getOutput(), "<question>GitHub User</question> ");
     self::$pass = $dialog->askHiddenResponse($this->getOutput(), "   <question>Password</question> ");
     return $this;
 }
Ejemplo n.º 4
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->app = $this->getApplication();
     $dialog = new DialogHelper();
     if (!empty($this->app->config['AuthToken'])) {
         $this->app->fogbugz = new FogBugz\Api($this->app->config['User'], '', $this->app->config['Host']);
         // The api used to login on instantiation, now we keep this token
         $this->app->fogbugz->token = $this->app->config['AuthToken'];
         if (!$input->getOption('quiet')) {
             $output->writeln("\nYou're already in as <info>" . $this->app->config['User'] . "</info>.\nUse the logout command to terminate this session.\n");
         }
         // TODO: Test this token, and re-prompt if it fails
         return;
     }
     $output->writeln("\n<comment>Please Login to FogBugz</comment>");
     $user = $dialog->ask($output, " * Email address: ", getenv("GIT_AUTHOR_EMAIL"));
     $password = $this->promptSilent(" * Password: "******"   <info>You're in. Use the logout command to terminate this session.</info>");
     } catch (FogBugz\ApiLogonError $e) {
         $output->writeln("\n<error>" . $e->getMessage() . "</error>\n");
         exit(1);
     }
     // Write the config and the token out to the config file
 }
Ejemplo n.º 5
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->app = $this->getApplication();
     $dialog = new DialogHelper();
     $case = $input->getArgument('case');
     if (null == $case) {
         $case = $this->app->getCurrent();
         if ($case == null || $case == 0) {
             $case = $dialog->ask($output, "Enter a case number: ");
         }
     }
     $url = trim($this->app->fogbugz->url, "/") . "/default.asp?" . $case;
     switch (PHP_OS) {
         case 'Darwin':
             exec("open {$url}");
             break;
         case 'WIN32':
         case 'WINNT':
             exec("cmd /c \"start {$url}\"");
             break;
         case 'Linux':
         case 'Unix':
         case 'NetBSD':
         case 'OpenBSD':
             exec("xdg-open {$url}");
             break;
         default:
             $output->writeln("<error>Your operating system (" . PHP_OS . ") isn't supported for the open command.</error>", $this->app->outputFormat);
     }
 }
Ejemplo n.º 6
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $dialog = new DialogHelper();
     if (!$input->getOption('silent')) {
         $confirmed = $dialog->askConfirmation($output, "This will install all TestGuy dependencies through PEAR installer.\n" . "PHPUnit, Symfony Components, and Mink will be installed.\n" . "Make shure this script has permission to install PEAR packages.\n" . "Do you want to proceed? (Y/n)");
         if (!$confirmed) {
             return;
         }
     }
     $output->writeln('Intalling PHPUnit...');
     $output->write(shell_exec('pear config-set auto_discover 1'));
     $output->write(shell_exec('pear install --alldeps pear.phpunit.de/PHPUnit'));
     $output->writeln("Installing Symfony Components...");
     $output->write(shell_exec("pear channel-discover pear.symfony.com"));
     $output->write(shell_exec('pear install symfony2/Finder'));
     $output->write(shell_exec('pear install symfony2/Process'));
     $output->write(shell_exec('pear install symfony2/CssSelector'));
     $output->write(shell_exec('pear install symfony2/DomCrawler'));
     $output->write(shell_exec('pear install symfony2/BrowserKit'));
     $output->writeln("Installing Mink...");
     $output->write(shell_exec("pear channel-discover pear.behat.org"));
     $output->write(shell_exec("pear install behat/mink"));
     $output->writeln('Please check PHPUnit was installed sucessfully. Run the "phpunit" command. If it is not avaible try installing PHPUnit manually');
     $output->writeln("Installaction complete. Init your new TestGuy suite calling the 'init' command");
 }
Ejemplo n.º 7
0
 public function ask($question, $regex, $errorText = null, $default = null)
 {
     if ($default) {
         $question = "{$question} [{$default}]";
     }
     return $this->dialog->askAndValidate($this->output, "<question>{$question}</question> ", $this->validateWith($regex, $errorText), false, $default);
 }
Ejemplo n.º 8
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->app = $this->getApplication();
     $dialog = new DialogHelper();
     $case = $input->getArgument('case');
     $note = $input->getArgument('note');
     // fb note "string message" and so we swap case and note
     if (!is_numeric($case)) {
         $note = $case;
         $case = $this->app->getCurrent();
         if (empty($case)) {
             $case = $dialog->ask($output, 'Enter a case number:');
         }
     }
     if (empty($note)) {
         $note = $dialog->ask($output, sprintf("Please supply a note for Case %d:\n", $case));
     }
     try {
         $this->app->fogbugz->edit(array('ixBug' => $case, 'sEvent' => $note));
         $output->writeln(sprintf('Left a note on case %s', $case), $this->app->outputFormat);
     } catch (ApiError $e) {
         $output->writeln(sprintf('<error>%s</error>', $e->getMessage()), $this->app->outputFormat);
         exit(1);
     }
 }
Ejemplo n.º 9
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->app = $this->getApplication();
     $dialog = new DialogHelper();
     // TODO: this should be config dir
     if (file_exists($this->app->configFile)) {
         $this->config = Yaml::parse($this->app->configFile);
     } else {
         $this->config = $this->app->getDefaultConfig();
     }
     $output->writeln(sprintf("%s\n<info>%s</info>\n%s\n Config Path: %s\n", str_repeat("—", 80), str_pad("FogBugz Client Setup", 80, " ", STR_PAD_BOTH), str_repeat("—", 80), $this->app->configFile), $this->app->outputFormat);
     // Prompt the values in the config file
     $question = "Enable color output (";
     $question .= !empty($this->config['UseColor']) && $this->config['UseColor'] ? "yes" : "no";
     $question .= "): ";
     $useColor = $dialog->ask($output, $question, $this->config['UseColor']);
     $this->config['UseColor'] = strtolower($useColor[0]) == 'y';
     // TODO: use validation here for host prompt
     $question = "FogBugz host url (";
     $question .= !empty($this->config['Host']) && $this->config['Host'] ? $this->config['Host'] : "include https://";
     $question .= "): ";
     $this->config['Host'] = $dialog->ask($output, $question, $this->config['Host']);
     // We can use this config to know if we need to make changes in setup
     $this->config['ConfigVersion'] = $this->app->project->version;
     $this->app->config = $this->config;
     $this->app->saveConfig();
     // Display the alias to use in bash config.
 }
Ejemplo n.º 10
0
 /**
  * Asks user what the path to Php source is.
  */
 public function configure()
 {
     $default = $this->settings->getDefaultValueFor('enablePhpTools', true);
     $this->settings['enablePhpTools'] = $this->dialog->askConfirmation($this->output, "\nDo you want to install the QA tools for PHP?", $default);
     if ($this->settings['enablePhpTools']) {
         $this->output->writeln("\n<info>Configuring PHP inspections</info>\n");
     }
 }
 public function configure()
 {
     if (!$this->settings['enablePhpTools']) {
         $this->settings['enableComposer'] = false;
         return false;
     }
     $this->settings['enableComposer'] = $this->dialog->askConfirmation($this->output, "Do you want to run `./composer.phar install` on every commit?", $this->settings->getDefaultValueFor('enableComposer', false));
 }
 public function configure()
 {
     if (!$this->settings['enablePhpTools']) {
         $this->settings['enablePhpSecurityChecker'] = false;
         return false;
     }
     $default = $this->settings->getDefaultValueFor('enablePhpSecurityChecker', true);
     $this->settings['enablePhpSecurityChecker'] = $this->dialog->askConfirmation($this->output, "Do you want to enable the Sensiolabs Security Checker?", $default);
 }
Ejemplo n.º 13
0
 public function testExecute()
 {
     $this->dialog->expects($this->at(0))->method('askAndValidate')->will($this->returnValue('*****@*****.**'));
     $this->dialog->expects($this->at(1))->method('ask')->will($this->returnValue('A name'));
     $this->dialog->expects($this->at(2))->method('askHiddenResponse')->will($this->returnValue('foobar123'));
     $commandTester = $this->getCommandTester();
     $commandTester->execute([]);
     $this->assertEquals('User account created!' . PHP_EOL, $commandTester->getDisplay());
 }
 /**
  *
  */
 public function configure()
 {
     if (!$this->settings['enablePhpTools']) {
         $this->settings['enablePhpLint'] = false;
         return false;
     }
     $default = $this->settings->getDefaultValueFor('enablePhpLint', true);
     $this->settings['enablePhpLint'] = $this->dialog->askConfirmation($this->output, "Do you want to enable PHP Lint?", $default);
 }
Ejemplo n.º 15
0
 /**
  * @param  OutputInterface $output
  * @param  DialogHelper    $dialog
  * @return array
  */
 public function getValues(OutputInterface $output, DialogHelper $dialog)
 {
     $default = $this->getDefault();
     $value = $dialog->ask($output, "<info>Package Name</info> ({$default}): ", $default);
     $parts = explode('/', $default);
     $owner = $parts[0];
     $title = isset($parts[1]) ? $parts[1] : $default;
     return ['package_name' => $value, 'package_owner' => $owner, 'package_title' => $title, 'package_classname' => $this->toCamelCase($title)];
 }
Ejemplo n.º 16
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->app = $this->getApplication();
     $dialog = new DialogHelper();
     $case = $input->getArgument('case');
     $recentCases = $this->app->getRecent();
     if ($case == null) {
         $strlen = 4;
         if (!empty($recentCases)) {
             $output->writeln("What case are you working on?", $this->app->outputFormat);
             foreach ($recentCases as $recent_case) {
                 $output->writeln(sprintf("  <info>[%s]</info> %s", $recent_case['id'], substr($recent_case['title'], 0, 75)), $this->app->outputFormat);
                 // this is just for display purposes below
                 $strlen = strlen($recent_case['id']);
             }
             $output->writeln("  <info>[" . str_repeat('#', $strlen) . "]</info> Or type any other case number to start work", $this->app->outputFormat);
         }
         while ($case == null) {
             $case = $dialog->ask($output, "Case number: ");
         }
     }
     try {
         // We'll go ahead and look it up, and if we find it, we'll
         // save it to recent. Then, we'll issue the command and catch
         // any problems with it and deal with it then.
         $bug = $this->app->fogbugz->search(array('q' => (int) $case, 'cols' => 'sTitle,sStatus,sLatestTextSummary'));
         $title = (string) $bug->cases->case->sTitle;
         $this->app->pushRecent($case, $title);
         $this->app->fogbugz->startWork(array('ixBug' => $case));
         $output->writeln(sprintf("Now working on [%d]\n  %s\n", $case, $title), $this->app->outputFormat);
     } catch (ApiError $e) {
         if ($e->getCode() == '7') {
             if ($e->getMessage() == 'Case ' . $case . ' has no estimate') {
                 $output->writeln(sprintf("<alert>Case %s has no estimate.</alert>", $case), $this->app->outputFormat);
                 // Delegate to the set estimate
                 $command = $this->getApplication()->find('estimate');
                 $arguments = array('command' => 'estimate', 'case' => $case);
                 $input = new ArrayInput($arguments);
                 $command->run($input, $output);
                 // Now come back to start the case.
                 // TODO: move this to call, so we aren't working the catch.
                 $title = (string) $bug->cases->case->sTitle;
                 $this->app->fogbugz->startWork(array('ixBug' => $case));
                 $output->writeln(sprintf("Now working on [%d]\n  %s\n", $case, $title), $this->app->outputFormat);
                 return;
             } elseif ($e->getMessage() == 'Closed') {
                 $output->writeln(sprintf("<fire>Sorry, Case %s is closed and may not " . "have a time interval added to it.</fire>", $case), $this->app->outputFormat);
             } else {
                 $output->writeln(sprintf("<error>%s</error>", $e->getMessage()), $this->app->outputFormat);
             }
         } else {
             $output->writeln(sprintf("<error>%s</error>", $e->getMessage()), $this->app->outputFormat);
         }
         exit(1);
     }
 }
Ejemplo n.º 17
0
 /**
  * @param  OutputInterface $output
  * @param  DialogHelper    $dialog
  * @return array
  */
 public function getValues(OutputInterface $output, DialogHelper $dialog)
 {
     $defaults = $this->getDefaults();
     $value = $dialog->askAndValidate($output, "<info>PHP Namespace</info> ({$defaults[0]}): ", function ($namespace) {
         if (preg_match("/^([\\w\\\\]+)*\\w+\$/", $namespace)) {
             return $namespace;
         }
         throw new RuntimeException(sprintf('%s is not a valid namespace', $namespace));
     }, false, reset($defaults), $defaults);
     return ['php_namespace' => $value, 'php_namespace_escaped' => addslashes($value)];
 }
Ejemplo n.º 18
0
 /**
  * @param  OutputInterface $output
  * @param  DialogHelper    $dialog
  * @return array
  */
 public function getValues(OutputInterface $output, DialogHelper $dialog)
 {
     $default = $this->getDefault();
     $value = $dialog->askAndValidate($output, "<info>Issues url</info> ({$default}): ", function ($email) {
         if (false === filter_var($email, FILTER_VALIDATE_URL)) {
             throw new RuntimeException('Not a valid url');
         }
         return $email;
     }, false, $default);
     return ['bugs' => $value];
 }
Ejemplo n.º 19
0
 public function testRun()
 {
     $app = $this->getApp();
     $command = new LogClear($app);
     $dialog = new DialogHelper();
     $dialog->setInputStream($this->getInputStream("Yes\n"));
     $command->setHelperSet(new HelperSet(array($dialog)));
     $tester = new CommandTester($command);
     $tester->execute(array());
     $result = $tester->getDisplay();
     $this->assertRegexp('/System & change logs cleared/', $result);
 }
 public function configure()
 {
     if (!$this->settings['enablePhpTools']) {
         $this->settings['enablePhpMessDetector'] = false;
         return false;
     }
     $default = $this->settings->getDefaultValueFor('enablePhpMessDetector', true);
     $this->settings['enablePhpMessDetector'] = $this->dialog->askConfirmation($this->output, "Do you want to enable the PHP Mess Detector?", $default);
     // Exclude default patterns
     $default = $this->settings->getDefaultValueFor('phpMdExcludePatterns', array());
     $excludePatterns = $this->multiplePathHelper->askPatterns("  - Which patterns should be excluded for PHP Mess Detector?", implode(',', $default), "  - Do you want to exclude custom patterns for PHP Mess Detector?", !empty($default));
     $this->settings['phpMdExcludePatterns'] = $excludePatterns;
 }
Ejemplo n.º 21
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->app = $this->getApplication();
     $dialog = new DialogHelper();
     $case = $input->getArgument('case');
     $note = $input->getArgument('note');
     // fb note "string message" and so we swap case and note
     if (!is_numeric($case)) {
         $note = $case;
         $case = $this->app->getCurrent();
         if (empty($case)) {
             $case = $dialog->ask($output, "Enter a case number:");
         } else {
             $output->writeln(sprintf("<notice>Resolving current Case %d.</notice>", $case), $this->app->outputFormat);
         }
     }
     $category = $this->app->fogbugz->search(array('q' => (int) $case, 'cols' => 'ixCategory'));
     $category = (int) $category->cases->case->ixCategory;
     $statuses = $this->app->fogbugz->listStatuses(array('fResolved' => 1, 'ixCategory' => (int) $category));
     foreach ($statuses->statuses->status as $status) {
         $output->writeln(sprintf("  <info>[%d]</info> %s", $status->ixStatus, $status->sStatus), $this->app->outputFormat);
     }
     $status = "";
     while (!is_numeric($status)) {
         $status = $dialog->ask($output, 'Enter the status from the list above: ');
     }
     $activePeople = $this->app->fogbugz->listPeople(array('fIncludeActive' => 1));
     $virtualPeople = $this->app->fogbugz->listPeople(array('fIncludeVirtual' => 1));
     $output->writeln('<alert>Active Users</alert>');
     $i = 1;
     foreach (array($activePeople, $virtualPeople) as $people) {
         foreach ($people->people->person as $person) {
             $output->writeln(sprintf("  <info>[%s%d]</info> %s", strlen($person->ixPerson) - 1 ? '' : ' ', $person->ixPerson, $person->sFullName), $this->app->outputFormat);
         }
         $i && $output->writeln('<alert>Virtual Users</alert>');
         $i--;
     }
     // TODO: validate the `assignedto` var.
     $assignedto = $dialog->ask($output, "Who should the case be assigned to: ");
     if (empty($note)) {
         $note = $dialog->ask($output, sprintf("Please supply a note for Case %d (optional):\n", $case));
     }
     $request = array('ixStatus' => $status, 'ixBug' => $case, 'ixPersonAssignedTo' => $assignedto, 'sEvent' => empty($note) ? '' : $note);
     try {
         $this->app->fogbugz->resolve($request);
         printf("Resolved case %s\n", $case);
     } catch (ApiError $e) {
         $output->writeln(sprintf("<error>%s</error>", $e->getMessage()), $this->app->outputFormat);
         exit(1);
     }
 }
 /**
  * Asks user what the path to javascript source is.
  */
 public function configure()
 {
     if (!$this->settings['enableJsHint']) {
         return;
     }
     $baseDir = $this->settings->getBaseDir();
     $default = $this->settings->getDefaultValueFor('javaScriptSrcPath', 'src');
     $this->settings['javaScriptSrcPath'] = $this->dialog->askAndValidate($this->output, "What is the path to the JavaScript source code? [{$default}] ", function ($data) use($baseDir) {
         if (is_dir($baseDir . '/' . $data)) {
             return $data;
         }
         throw new \Exception("That path doesn't exist");
     }, false, $default);
 }
Ejemplo n.º 23
0
 public function interact(DialogHelper $dialog, OutputInterface $output, array $answers)
 {
     #Database user Name
     $answers['username'] = $dialog->ask($output, '<question>What is the Database user name? [false] : </question>', false);
     #Database user Password
     $answers['password'] = $dialog->ask($output, '<question>What is the Database users password? [false] : </question>', false);
     if ($dialog->askConfirmation($output, '<question>Using in memory database? [y|n] : </question>', false)) {
         $answers['memory'] = ':memory';
     } else {
         #Database path
         $answers['path'] = $dialog->ask($output, '<question>What is the Database path relative to project root? : </question>', false);
     }
     return $answers;
 }
 /**
  * Check that Magento is not removed if confirmation is denied
  */
 public function testUninstallDoesNotUninstallIfConfirmationDenied()
 {
     $application = $this->getApplication();
     $application->add(new UninstallCommand());
     $command = $this->getApplication()->find('uninstall');
     $commandTester = new CommandTester($command);
     $dialog = new DialogHelper();
     $dialog->setInputStream($this->getInputStream('no\\n'));
     $command->setHelperSet(new HelperSet(array($dialog)));
     $commandTester->execute(array('command' => $command->getName(), '--installationFolder' => $this->getTestMagentoRoot()));
     $this->assertEquals("Really uninstall ? [n]: ", $commandTester->getDisplay());
     //check magento still installed
     $this->assertFileExists($this->getTestMagentoRoot() . '/app/etc/local.xml');
 }
Ejemplo n.º 25
0
 /**
  * Truncate the Queue and Transition and Monitor Tables
  *
  * @param InputInterface $input An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dialog = new DialogHelper();
     $answer = $dialog->askConfirmation($output, '<info>Run Truncate</info> will <info>erase</info> stored jobs and transitions? [y|n] :', false);
     if ($answer) {
         $queue = $this->getHelper('queue')->getQueue();
         $db_config = $queue['config.database'];
         $doctrine = $queue['doctrine'];
         $output->writeln('Starting Truncate Database Tables');
         $doctrine->exec('TRUNCATE ' . $doctrine->getDatabase() . '.' . $db_config->getTransitionTableName());
         $doctrine->exec('TRUNCATE ' . $doctrine->getDatabase() . '.' . $db_config->getQueueTableName());
         $doctrine->exec('TRUNCATE ' . $doctrine->getDatabase() . '.' . $db_config->getMonitorTableName());
         $output->writeln('Finished Truncate Database Tables');
     }
 }
 public function configure()
 {
     if (!$this->settings['enablePhpTools']) {
         $this->settings['enablePhpCopyPasteDetection'] = false;
         return;
     }
     $default = $this->settings->getDefaultValueFor('enablePhpCopyPasteDetection', false);
     $this->settings['enablePhpCopyPasteDetection'] = $this->dialog->askConfirmation($this->output, "Do you want to enable PHP Copy Paste Detection?", $default);
     if (!$this->settings['enablePhpCopyPasteDetection']) {
         return;
     }
     // Tests is the Symfony default
     $default = $this->settings->getDefaultValueFor('phpCpdExcludePatterns', 'Tests');
     $this->settings['phpCpdExcludePatterns'] = $this->multiplePathHelper->askPatterns(" - Which patterns should be excluded for PHP Copy Paste detection?", $default, " - Do you want to exclude patterns for PHP Copy Paste detection?");
 }
Ejemplo n.º 27
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->app = $this->getApplication();
     $dialog = new DialogHelper();
     $filter = $input->getArgument('filter');
     if (null === $filter) {
         $command = $this->getApplication()->find('filters');
         $arguments = array('command' => 'filters');
         $input = new ArrayInput($arguments);
         $command->run($input, $output);
         $filter = $dialog->ask($output, "Enter a filter number: ");
     }
     $this->app->fogbugz->setCurrentFilter(array('sFilter' => $filter));
     $output->writeln(sprintf("Set the current active filter to: %s", $filter), $this->app->outputFormat);
 }
 public function configure()
 {
     if (!$this->settings['enableJsTools']) {
         $this->settings['enableJsHint'] = false;
         return;
     }
     $default = $this->settings->getDefaultValueFor('enableJsHint', true);
     $this->settings['enableJsHint'] = $this->dialog->askConfirmation($this->output, "Do you want to enable JSHint?", $default);
     if ($this->settings['enableJsHint'] === false) {
         return;
     }
     $statusCode = $this->installJsHintCommand->run($this->input, $this->output);
     if ($statusCode) {
         $this->settings['enableJsHint'] = false;
     }
 }
Ejemplo n.º 29
0
 protected function createInstance()
 {
     $entities = entity_get_info();
     $entityList = array_keys($entities);
     $entity = $this->dialog->select($this->output, 'What entity? ', $entityList);
     $entity = $entityList[$entity];
     $bundles = field_info_bundles($entity);
     $bundleList = array_keys($bundles);
     $bundle = $this->dialog->select($this->output, 'What bundle? ', $bundleList);
     $bundle = $bundleList[$bundle];
     $field_types = FieldBuilder::getFields();
     $fieldList = array();
     foreach ($field_types as $field => $definition) {
         $fieldList[$field] = sprintf("%s (%s)", $definition['label'], $field);
     }
     $fieldValues = array_keys($field_types);
     $field = $this->dialog->select($this->output, 'Field To Attach', array_values($fieldList));
     $field = $fieldValues[$field];
     $widget_types = WidgetBuilder::getTypesForFieldType($field_types[$field]['type']);
     $widgetList = array_keys($widget_types);
     $widget = $this->dialog->select($this->output, 'Widget to Use', array_values($widget_types));
     $widget = $widgetList[$widget];
     $label = $this->dialog->ask($this->output, 'What label for this instance? ');
     $widgetDefinition = new WidgetBuilder($widget, $label);
     $builder = new InstanceBuilder($field, $label, $widgetDefinition);
     $builder->build($entity, $bundle);
     $this->output->writeln("Created instance of field {$field} with label <info>{$label}</info> on {$entity}:{$bundle}");
     $this->mainQuestion();
 }
Ejemplo n.º 30
0
 /**
  * @param string $name
  */
 private function iExecuteCommandAndConfirm($name)
 {
     $this->dialog = $this->command->getHelper('dialog');
     $inputString = 'y' . PHP_EOL;
     $this->dialog->setInputStream($this->getInputStream($inputString));
     $this->tester->execute(['command' => $name]);
 }