Skip to content

Commit

Permalink
Making the user message a little nicer
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverryan committed Feb 27, 2018
1 parent 663afee commit 2fd2e0c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/Maker/MakeEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,10 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen

$manipulator = $this->createClassManipulator($entityPath, $io, $overwrite);

$isFirstField = true;
while (true) {
$newField = $this->askForNextField($io, $currentFields, $entityClassDetails->getFullName());
$newField = $this->askForNextField($io, $currentFields, $entityClassDetails->getFullName(), $isFirstField);
$isFirstField = false;

if (null === $newField) {
break;
Expand Down Expand Up @@ -276,10 +278,17 @@ public function configureDependencies(DependencyBuilder $dependencies)
);
}

private function askForNextField(ConsoleStyle $io, array $fields, string $entityClass)
private function askForNextField(ConsoleStyle $io, array $fields, string $entityClass, bool $isFirstField)
{
$io->writeln('');
$fieldName = $io->ask('New property name (press <return> to stop adding fields)', null, function ($name) use ($fields) {

if ($isFirstField) {
$questionText = 'New property name (press <return> to stop adding fields)';
} else {
$questionText = 'Add another property? Enter the property name (or press <return> to stop adding fields)';
}

$fieldName = $io->ask($questionText, null, function ($name) use ($fields) {
// allow it to be empty
if (!$name) {
return $name;
Expand Down

0 comments on commit 2fd2e0c

Please sign in to comment.