Skip to content

Commit

Permalink
Add autocompletion to generate:doctrine:entity
Browse files Browse the repository at this point in the history
  • Loading branch information
lmcd committed Dec 17, 2012
1 parent f968487 commit c627c67
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Command/GenerateDoctrineEntityCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,10 @@ protected function interact(InputInterface $input, OutputInterface $output)
''
));

$bundleNames = array_keys($this->getContainer()->get('kernel')->getBundles());

while (true) {
$entity = $dialog->askAndValidate($output, $dialog->getQuestion('The Entity shortcut name', $input->getOption('entity')), array('Sensio\Bundle\GeneratorBundle\Command\Validators', 'validateEntityName'), false, $input->getOption('entity'));
$entity = $dialog->askAndValidate($output, $dialog->getQuestion('The Entity shortcut name', $input->getOption('entity')), array('Sensio\Bundle\GeneratorBundle\Command\Validators', 'validateEntityName'), false, $input->getOption('entity'), $bundleNames);

list($bundle, $entity) = $this->parseShortcutNotation($entity);

Expand Down Expand Up @@ -148,7 +150,10 @@ protected function interact(InputInterface $input, OutputInterface $output)
'Determine the format to use for the mapping information.',
'',
));
$format = $dialog->askAndValidate($output, $dialog->getQuestion('Configuration format (yml, xml, php, or annotation)', $input->getOption('format')), array('Sensio\Bundle\GeneratorBundle\Command\Validators', 'validateFormat'), false, $input->getOption('format'));

$formats = array('yml', 'xml', 'php', 'annotation');

$format = $dialog->askAndValidate($output, $dialog->getQuestion('Configuration format (yml, xml, php, or annotation)', $input->getOption('format')), array('Sensio\Bundle\GeneratorBundle\Command\Validators', 'validateFormat'), false, $input->getOption('format'), $formats);
$input->setOption('format', $format);

// fields
Expand Down Expand Up @@ -278,7 +283,7 @@ private function addFields(InputInterface $input, OutputInterface $output, Dialo
$defaultType = 'boolean';
}

$type = $dialog->askAndValidate($output, $dialog->getQuestion('Field type', $defaultType), $fieldValidator, false, $defaultType);
$type = $dialog->askAndValidate($output, $dialog->getQuestion('Field type', $defaultType), $fieldValidator, false, $defaultType, $types);

$data = array('columnName' => $columnName, 'fieldName' => lcfirst(Container::camelize($columnName)), 'type' => $type);

Expand Down

0 comments on commit c627c67

Please sign in to comment.