Improve text for asking questions/errors

This commit is contained in:
Tim 2022-10-25 13:11:38 +02:00
parent f4a4362592
commit 991c552a46

View File

@ -52,13 +52,14 @@ abstract class AbstractEntityCommand extends Command
$builder->setAll($entity);
$this->em->persist($entity);
if ($io->askQuestion(new ConfirmationQuestion(sprintf('Are you sure you want to create "%s" with above properties', $entity)))) {
if ($io->askQuestion(new ConfirmationQuestion(sprintf('Are you sure you want to create "%s" with above properties?', $entity)))) {
$io->success(sprintf('Object "%s" stored successfully', $entity));
}
} while ($io->askQuestion(new ConfirmationQuestion('Create another entity?', false)));
} elseif ($input->getOption('modify')) {
$io->info(sprintf('Modifying "%s"', $this->getEntityClass()));
$entity = $this->select($io, $id);
do {
$builder->setByQuestion($entity);
} while ($io->askQuestion(new ConfirmationQuestion('Modify another property?')));
@ -66,7 +67,8 @@ abstract class AbstractEntityCommand extends Command
} elseif ($input->getOption('delete')) {
$io->info(sprintf('Deleting "%s"', $this->getEntityClass()));
$entity = $this->select($io, $id);
if ($io->askQuestion(new ConfirmationQuestion(sprintf('Are you sure you want to delete %s', $entity)))) {
if ($io->askQuestion(new ConfirmationQuestion(sprintf('Are you sure you want to delete %s?', $entity)))) {
$name = (string)$entity;
$this->em->remove($entity);
$io->success(sprintf('Config "%s" deleted', $name));
@ -74,6 +76,7 @@ abstract class AbstractEntityCommand extends Command
} elseif ($input->getOption('show')) {
$io->info(sprintf('Showing "%s"', $this->getEntityClass()));
$entity = $this->select($io, $id);
$table = $io->createTable();
$table->setHeaders(['property', 'value']);
$table->setRows($builder->getAllPropertiesTable($entity));
@ -82,13 +85,14 @@ abstract class AbstractEntityCommand extends Command
} elseif ($input->getOption('all')) {
$io->info(sprintf('Showing all %s', $this->getEntityClass()));
$entities = $this->em->getRepository($this->getEntityClass())->findAll();
$table = $io->createTable();
$table->setHeaders($builder->getPopertyNames());
$table->setRows(array_map(fn(object $o) => $builder->getAllProperties($o), $entities));
$table->setHeaderTitle($this->getEntityClass());
$table->render();
} else {
$io->error('Select at least one of the options: Create (-c), Modify (-m), Delete (-d) or Show (-s)');
$io->error('Select one of the options: Create (-c), Modify (-m), Delete (-d), Show (-s) or All (-a)');
return Command::INVALID;
}
@ -111,7 +115,7 @@ abstract class AbstractEntityCommand extends Command
if (empty($entities)) {
throw new Exception('No objects found');
}
$question = new ChoiceQuestion('Select configuration to delete', $entities);
return $io->askQuestion($question);
return $io->askQuestion(new ChoiceQuestion('Select the object', $entities));
}
}