Skip to content

Commit 8b7c291

Browse files
committed
Fix 'src/Entity' directory does not exist
1 parent 407a748 commit 8b7c291

File tree

1 file changed

+2
-31
lines changed

1 file changed

+2
-31
lines changed

src/Maker/MakeEntity.php

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
use Symfony\Component\Console\Input\InputOption;
3636
use Symfony\Component\Console\Question\ConfirmationQuestion;
3737
use Symfony\Component\Console\Question\Question;
38-
use Symfony\Component\Finder\SplFileInfo;
3938

4039
/**
4140
* @author Javier Eguiluz <[email protected]>
@@ -99,20 +98,6 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma
9998
return;
10099
}
101100

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-
116101
$argument = $command->getDefinition()->getArgument('name');
117102
$question = $this->createEntityClassQuestion($argument->getDescription());
118103
$value = $io->askQuestion($question);
@@ -362,7 +347,7 @@ private function askForNextField(ConsoleStyle $io, array $fields, string $entity
362347

363348
// this is a normal field
364349
$data = ['fieldName' => $fieldName, 'type' => $type];
365-
if ('string' == $type) {
350+
if ('string' === $type) {
366351
// default to 255, avoid the question
367352
$data['length'] = $io->ask('Field length', 255, [Validator::class, 'validateLength']);
368353
} elseif ('decimal' === $type) {
@@ -466,23 +451,9 @@ private function printAvailableTypes(ConsoleStyle $io)
466451

467452
private function createEntityClassQuestion(string $questionText): Question
468453
{
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-
483454
$question = new Question($questionText);
484455
$question->setValidator([Validator::class, 'notBlank']);
485-
$question->setAutocompleterValues($classes);
456+
$question->setAutocompleterValues($this->doctrineHelper->getEntitiesForAutocomplete());
486457

487458
return $question;
488459
}

0 commit comments

Comments
 (0)