|
35 | 35 | use Symfony\Component\Console\Input\InputOption; |
36 | 36 | use Symfony\Component\Console\Question\ConfirmationQuestion; |
37 | 37 | use Symfony\Component\Console\Question\Question; |
38 | | -use Symfony\Component\Finder\SplFileInfo; |
39 | 38 |
|
40 | 39 | /** |
41 | 40 | * @author Javier Eguiluz <[email protected]> |
@@ -99,20 +98,6 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma |
99 | 98 | return; |
100 | 99 | } |
101 | 100 |
|
102 | | - $entityFinder = $this->fileManager->createFinder('src/Entity/') |
103 | | - // remove if/when we allow entities in subdirectories |
104 | | - ->depth('<1') |
105 | | - ->name('*.php'); |
106 | | - $classes = []; |
107 | | - /** @var SplFileInfo $item */ |
108 | | - foreach ($entityFinder as $item) { |
109 | | - if (!$item->getRelativePathname()) { |
110 | | - continue; |
111 | | - } |
112 | | - |
113 | | - $classes[] = str_replace(['.php', '/'], ['', '\\'], $item->getRelativePathname()); |
114 | | - } |
115 | | - |
116 | 101 | $argument = $command->getDefinition()->getArgument('name'); |
117 | 102 | $question = $this->createEntityClassQuestion($argument->getDescription()); |
118 | 103 | $value = $io->askQuestion($question); |
@@ -362,7 +347,7 @@ private function askForNextField(ConsoleStyle $io, array $fields, string $entity |
362 | 347 |
|
363 | 348 | // this is a normal field |
364 | 349 | $data = ['fieldName' => $fieldName, 'type' => $type]; |
365 | | - if ('string' == $type) { |
| 350 | + if ('string' === $type) { |
366 | 351 | // default to 255, avoid the question |
367 | 352 | $data['length'] = $io->ask('Field length', 255, [Validator::class, 'validateLength']); |
368 | 353 | } elseif ('decimal' === $type) { |
@@ -466,23 +451,9 @@ private function printAvailableTypes(ConsoleStyle $io) |
466 | 451 |
|
467 | 452 | private function createEntityClassQuestion(string $questionText): Question |
468 | 453 | { |
469 | | - $entityFinder = $this->fileManager->createFinder('src/Entity/') |
470 | | - // remove if/when we allow entities in subdirectories |
471 | | - ->depth('<1') |
472 | | - ->name('*.php'); |
473 | | - $classes = []; |
474 | | - /** @var SplFileInfo $item */ |
475 | | - foreach ($entityFinder as $item) { |
476 | | - if (!$item->getRelativePathname()) { |
477 | | - continue; |
478 | | - } |
479 | | - |
480 | | - $classes[] = str_replace('/', '\\', str_replace('.php', '', $item->getRelativePathname())); |
481 | | - } |
482 | | - |
483 | 454 | $question = new Question($questionText); |
484 | 455 | $question->setValidator([Validator::class, 'notBlank']); |
485 | | - $question->setAutocompleterValues($classes); |
| 456 | + $question->setAutocompleterValues($this->doctrineHelper->getEntitiesForAutocomplete()); |
486 | 457 |
|
487 | 458 | return $question; |
488 | 459 | } |
|
0 commit comments