Improve text for asking questions/errors
This commit is contained in:
parent
f4a4362592
commit
991c552a46
@ -52,13 +52,14 @@ abstract class AbstractEntityCommand extends Command
|
|||||||
$builder->setAll($entity);
|
$builder->setAll($entity);
|
||||||
$this->em->persist($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));
|
$io->success(sprintf('Object "%s" stored successfully', $entity));
|
||||||
}
|
}
|
||||||
} while ($io->askQuestion(new ConfirmationQuestion('Create another entity?', false)));
|
} while ($io->askQuestion(new ConfirmationQuestion('Create another entity?', false)));
|
||||||
} elseif ($input->getOption('modify')) {
|
} elseif ($input->getOption('modify')) {
|
||||||
$io->info(sprintf('Modifying "%s"', $this->getEntityClass()));
|
$io->info(sprintf('Modifying "%s"', $this->getEntityClass()));
|
||||||
$entity = $this->select($io, $id);
|
$entity = $this->select($io, $id);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$builder->setByQuestion($entity);
|
$builder->setByQuestion($entity);
|
||||||
} while ($io->askQuestion(new ConfirmationQuestion('Modify another property?')));
|
} while ($io->askQuestion(new ConfirmationQuestion('Modify another property?')));
|
||||||
@ -66,7 +67,8 @@ abstract class AbstractEntityCommand extends Command
|
|||||||
} elseif ($input->getOption('delete')) {
|
} elseif ($input->getOption('delete')) {
|
||||||
$io->info(sprintf('Deleting "%s"', $this->getEntityClass()));
|
$io->info(sprintf('Deleting "%s"', $this->getEntityClass()));
|
||||||
$entity = $this->select($io, $id);
|
$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;
|
$name = (string)$entity;
|
||||||
$this->em->remove($entity);
|
$this->em->remove($entity);
|
||||||
$io->success(sprintf('Config "%s" deleted', $name));
|
$io->success(sprintf('Config "%s" deleted', $name));
|
||||||
@ -74,6 +76,7 @@ abstract class AbstractEntityCommand extends Command
|
|||||||
} elseif ($input->getOption('show')) {
|
} elseif ($input->getOption('show')) {
|
||||||
$io->info(sprintf('Showing "%s"', $this->getEntityClass()));
|
$io->info(sprintf('Showing "%s"', $this->getEntityClass()));
|
||||||
$entity = $this->select($io, $id);
|
$entity = $this->select($io, $id);
|
||||||
|
|
||||||
$table = $io->createTable();
|
$table = $io->createTable();
|
||||||
$table->setHeaders(['property', 'value']);
|
$table->setHeaders(['property', 'value']);
|
||||||
$table->setRows($builder->getAllPropertiesTable($entity));
|
$table->setRows($builder->getAllPropertiesTable($entity));
|
||||||
@ -82,13 +85,14 @@ abstract class AbstractEntityCommand extends Command
|
|||||||
} elseif ($input->getOption('all')) {
|
} elseif ($input->getOption('all')) {
|
||||||
$io->info(sprintf('Showing all %s', $this->getEntityClass()));
|
$io->info(sprintf('Showing all %s', $this->getEntityClass()));
|
||||||
$entities = $this->em->getRepository($this->getEntityClass())->findAll();
|
$entities = $this->em->getRepository($this->getEntityClass())->findAll();
|
||||||
|
|
||||||
$table = $io->createTable();
|
$table = $io->createTable();
|
||||||
$table->setHeaders($builder->getPopertyNames());
|
$table->setHeaders($builder->getPopertyNames());
|
||||||
$table->setRows(array_map(fn(object $o) => $builder->getAllProperties($o), $entities));
|
$table->setRows(array_map(fn(object $o) => $builder->getAllProperties($o), $entities));
|
||||||
$table->setHeaderTitle($this->getEntityClass());
|
$table->setHeaderTitle($this->getEntityClass());
|
||||||
$table->render();
|
$table->render();
|
||||||
} else {
|
} 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;
|
return Command::INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +115,7 @@ abstract class AbstractEntityCommand extends Command
|
|||||||
if (empty($entities)) {
|
if (empty($entities)) {
|
||||||
throw new Exception('No objects found');
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user