Imrove feedback
This commit is contained in:
parent
1888923d28
commit
b68b4564df
@ -45,6 +45,7 @@ abstract class AbstractEntityCommand extends Command
|
||||
$this->getConfig($builder);
|
||||
|
||||
if ($input->getOption('create')) {
|
||||
$io->info(sprintf('Creating new "%s"', $this->getEntityClass()));
|
||||
$entity = new ($this->getEntityClass())();
|
||||
$builder->setAll($entity);
|
||||
|
||||
@ -52,9 +53,11 @@ abstract class AbstractEntityCommand extends Command
|
||||
$io->success(sprintf('Object "%s" (id: %s) stored successfully', $entity, $entity->getId()));
|
||||
}
|
||||
} elseif ($input->getOption('modify')) {
|
||||
$io->info(sprintf('Modifying "%s"', $this->getEntityClass()));
|
||||
$entity = $this->select($io, $id);
|
||||
$builder->setByQuestion($entity);
|
||||
} 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)))) {
|
||||
$name = (string)$entity;
|
||||
@ -62,6 +65,7 @@ abstract class AbstractEntityCommand extends Command
|
||||
$io->success(sprintf('Config "%s" deleted', $name));
|
||||
}
|
||||
} elseif ($input->getOption('show')) {
|
||||
$io->info(sprintf('Showing "%s"', $this->getEntityClass()));
|
||||
$entity = $this->select($io, $id);
|
||||
$table = $io->createTable();
|
||||
$table->setHeaders(['property', 'value']);
|
||||
@ -69,8 +73,8 @@ abstract class AbstractEntityCommand extends Command
|
||||
$table->setHeaderTitle(sprintf('id: %s', $entity->getId()));
|
||||
$table->render();
|
||||
} else {
|
||||
$io->error('Select at least one of the options');
|
||||
return Command::FAILURE;
|
||||
$io->error('Select at least one of the options: Create (-c), Modify (-m), Delete (-d) or Show (-s)');
|
||||
return Command::INVALID;
|
||||
}
|
||||
|
||||
$this->em->persist($entity);
|
||||
|
Loading…
Reference in New Issue
Block a user