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