Skip to content

Fixed No directory for Entity issue #308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 1 addition & 29 deletions src/Maker/MakeEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,24 +99,9 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma
return;
}

$entityFinder = $this->fileManager->createFinder('src/Entity/')
// remove if/when we allow entities in subdirectories
->depth('<1')
->name('*.php');
$classes = [];
/** @var SplFileInfo $item */
foreach ($entityFinder as $item) {
if (!$item->getRelativePathname()) {
continue;
}

$classes[] = str_replace(['.php', '/'], ['', '\\'], $item->getRelativePathname());
}

$argument = $command->getDefinition()->getArgument('name');
$question = $this->createEntityClassQuestion($argument->getDescription());
$value = $io->askQuestion($question);

$input->setArgument('name', $value);

if (
Expand Down Expand Up @@ -466,20 +451,7 @@ private function printAvailableTypes(ConsoleStyle $io)

private function createEntityClassQuestion(string $questionText): Question
{
$entityFinder = $this->fileManager->createFinder('src/Entity/')
// remove if/when we allow entities in subdirectories
->depth('<1')
->name('*.php');
$classes = [];
/** @var SplFileInfo $item */
foreach ($entityFinder as $item) {
if (!$item->getRelativePathname()) {
continue;
}

$classes[] = str_replace('/', '\\', str_replace('.php', '', $item->getRelativePathname()));
}

$classes = $this->doctrineHelper->getEntitiesForAutocomplete();
$question = new Question($questionText);
$question->setValidator([Validator::class, 'notBlank']);
$question->setAutocompleterValues($classes);
Expand Down