protected function execute(InputInterface $input, OutputInterface $output)
{
$dialog = $this->getDialogHelper();
if ($input->isInteractive()) {
if (!$dialog->askConfirmation($output, $dialog->getQuestion('Do you confirm generation', 'yes', '?'), true)) {
$output->writeln('<error>Command aborted</error>');
return 1;
}
}
$entity = Validators::validateEntityName($input->getOption('entity'));
list($bundle, $entity) = $this->parseShortcutNotation($entity);
$format = Validators::validateFormat($input->getOption('format'));
$prefix = $this->getRoutePrefix($input, $entity);
$withWrite = $input->getOption('with-write');
$dialog->writeSection($output, 'CRUD generation');
$entityClass = $this->getContainer()->get('doctrine')->getEntityNamespace($bundle).'\\'.$entity;
$metadata = $this->getEntityMetadata($entityClass);
$bundle = $this->getContainer()->get('kernel')->getBundle($bundle);
$generator = $this->getGenerator();
$generator->generate($bundle, $entity, $metadata[0], $format, $prefix, $withWrite);
$output->writeln('Generating the CRUD code: <info>OK</info>');
$errors = array();
$runner = $dialog->getRunner($output, $errors);
// form
if ($withWrite) {
$this->generateForm($bundle, $entity, $metadata);
$output->writeln('Generating the Form code: <info>OK</info>');
}
// routing
if ('annotation' != $format) {
$runner($this->updateRouting($dialog, $input, $output, $bundle, $format, $entity, $prefix));
}
$dialog->writeGeneratorSummary($output, $errors);
}