Ejemplo n.º 1
0
 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dialog = $this->getQuestionHelper();
     if ($input->isInteractive()) {
         if (!$dialog->ask($input, $output, new ConfirmationQuestion($dialog->getQuestion('Do you confirm generation', 'yes', '?')), true)) {
             $output->writeln('<error>Command aborted</error>');
             return 1;
         }
     }
     $document = Validators::validateDocumentName($input->getOption('document'));
     list($bundle, $document) = $this->parseShortcutNotation($document);
     $format = Validators::validateFormat($input->getOption('format'));
     $prefix = $this->getRoutePrefix($input, $document);
     $withWrite = $input->getOption('with-write');
     $dialog->writeSection($output, 'CRUD generation');
     $documentClass = $this->getDocumentNamespace($bundle) . '\\' . $document;
     $metadata = $this->getDocumentMetadata($documentClass);
     $bundle = $this->getBundle($bundle);
     $generator = $this->getGenerator();
     $generator->generate($bundle, $document, $metadata, $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, $document, $metadata);
         $output->writeln('Generating the Form code: <info>OK</info>');
     }
     // routing
     if ('annotation' != $format) {
         call_user_func($runner, $this->updateRouting($dialog, $input, $output, $bundle, $format, $document, $prefix));
     }
     $dialog->writeGeneratorSummary($output, $errors);
     return 0;
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $document = Validators::validateDocumentName($input->getArgument('document'));
     list($bundle, $document) = $this->parseShortcutNotation($document);
     /** @var $application \Symfony\Bundle\FrameworkBundle\Console\Application */
     $application = $this->getApplication();
     /* @var $bundle \Symfony\Component\HttpKernel\Bundle\BundleInterface */
     $bundle = $application->getKernel()->getBundle($bundle);
     $documentClass = $bundle->getNamespace() . '\\Document\\' . $document;
     $metadata = $this->getDocumentMetadata($documentClass);
     $generator = new DoctrineFormGenerator($this->getSkeletonPath() . '/form');
     $generator->generate($bundle, $document, $metadata);
     $output->writeln(sprintf('The new %s.php class file has been created under %s.', $generator->getClassName(), $generator->getClassPath()));
 }
 /**
  * @throws \InvalidArgumentException When the bundle doesn't end with Bundle (Example: "Bundle/MySampleBundle")
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dialog = $this->getQuestionHelper();
     if ($input->isInteractive()) {
         $confirmationQuestion = new ConfirmationQuestion($dialog->getQuestion('Do you confirm generation', 'yes', '?'), true);
         if (!$dialog->ask($input, $output, $confirmationQuestion)) {
             $output->writeln('<error>Command aborted</error>');
             return 1;
         }
     }
     $document = Validators::validateDocumentName($input->getOption('document'));
     list($bundle, $document) = $this->parseShortcutNotation($document);
     $fields = $this->parseFields($input->getOption('fields'));
     $dialog->writeSection($output, 'Document generation');
     $bundle = $this->getKernel()->getBundle($bundle);
     $generator = $this->getGenerator();
     $generator->generate($bundle, $document, array_values($fields), $input->getOption('with-repository'));
     $output->writeln('Generating the document code: <info>OK</info>');
     $dialog->writeGeneratorSummary($output, array());
     return 0;
 }