/**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $questionHelper = $this->getQuestionHelper();
     $questionHelper->writeSection($output, 'Welcome to the Kunstmaan default site generator');
     $inputAssistant = GeneratorUtils::getInputAssistant($input, $output, $questionHelper, $this->getApplication()->getKernel(), $this->getContainer());
     $inputAssistant->askForNamespace(array('', 'This command helps you to generate tests to test the admin of the default site setup.', 'You must specify the namespace of the bundle where you want to generate the tests.', 'Use <comment>/</comment> instead of <comment>\\ </comment>for the namespace delimiter to avoid any problem.', ''));
 }
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $questionHelper = $this->getQuestionHelper();
     $questionHelper->writeSection($output, 'Welcome to the Kunstmaan Article generator');
     $inputAssistant = GeneratorUtils::getInputAssistant($input, $output, $questionHelper, $this->getApplication()->getKernel(), $this->getContainer());
     $inputAssistant->askForNamespace(array('', 'This command helps you to generate the Article classes.', 'You must specify the namespace of the bundle where you want to generate the classes in.', 'Use <comment>/</comment> instead of <comment>\\ </comment>for the namespace delimiter to avoid any problem.', ''));
     // entity
     $entity = $input->getOption('entity') ? $input->getOption('entity') : null;
     if (is_null($entity)) {
         $output->writeln(array('', 'You must specify a name for the collection of Article entities.', 'This name will be prefixed before every new entity.', 'For example entering <comment>News</comment> will result in:', '<comment>News</comment>OverviewPage, <comment>News</comment>Page and <comment>News</comment>Author', ''));
         $entityValidation = function ($entity) {
             if (empty($entity)) {
                 throw new \RuntimeException('You have to provide a entity name!');
             } elseif (!preg_match('/^[a-zA-Z][a-zA-Z_0-9]+$/', $entity)) {
                 throw new \InvalidArgumentException(sprintf("%s" . ' contains invalid characters', $entity));
             } else {
                 return $entity;
             }
         };
         $question = new Question($questionHelper->getQuestion('Name', $entity), $entity);
         $question->setValidator($entityValidation);
         $entity = $questionHelper->ask($input, $output, $question);
         $input->setOption('entity', $entity);
     }
     $inputAssistant->askForPrefix();
 }
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $dialog = $this->getDialogHelper();
     $dialog->writeSection($output, 'Welcome to the SearchPage generator');
     $inputAssistant = GeneratorUtils::getInputAssistant($input, $output, $dialog, $this->getApplication()->getKernel(), $this->getContainer());
     $inputAssistant->askForNamespace(array('', 'This command helps you to generate a SearchPage.', 'You must specify the namespace of the bundle where you want to generate the SearchPage in.', 'Use <comment>/</comment> instead of <comment>\\ </comment>for the namespace delimiter to avoid any problem.', ''));
     $inputAssistant->askForPrefix();
 }
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $questionHelper = $this->getQuestionHelper();
     $questionHelper->writeSection($output, 'Welcome to the Doctrine2 entity generator');
     // namespace
     $output->writeln(array('', 'This command helps you generate Doctrine2 entities.', '', 'First, you need to give the entity name you want to generate.', 'You must use the shortcut notation like <comment>AcmeBlogBundle:Post</comment>.', ''));
     $bundleNames = array_keys($this->getContainer()->get('kernel')->getBundles());
     /** @var $foundBundle Bundle */
     $foundBundle = $bundle = $entity = null;
     while (true) {
         $question = new Question($questionHelper->getQuestion('The Entity shortcut name', $input->getOption('entity')));
         $question->setValidator(array('Sensio\\Bundle\\GeneratorBundle\\Command\\Validators', 'validateEntityName'));
         $question->setAutocompleterValues($bundleNames);
         $entity = $questionHelper->ask($input, $output, $question);
         list($bundle, $entity) = $this->parseShortcutNotation($entity);
         // check entity name
         if (!preg_match('/^[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*$/', $entity)) {
             $output->writeln(sprintf('<bg=red> "%s" is not a valid entity name.</>', $entity));
             continue;
         }
         // check reserved words
         if ($this->getGenerator()->isReservedKeyword($entity)) {
             $output->writeln(sprintf('<bg=red> "%s" is a reserved word</>.', $entity));
             continue;
         }
         try {
             $foundBundle = $this->getContainer()->get('kernel')->getBundle($bundle);
             if (!file_exists($foundBundle->getPath() . '/Entity/' . str_replace('\\', '/', $entity) . '.php')) {
                 break;
             }
             $output->writeln(sprintf('<bg=red>Entity "%s:%s" already exists</>.', $bundle, $entity));
         } catch (\Exception $e) {
             $output->writeln(sprintf('<bg=red>Bundle "%s" does not exist.</>', $bundle));
         }
     }
     $input->setOption('entity', $bundle . ':' . $entity);
     $inputAssistant = GeneratorUtils::getInputAssistant($input, $output, $questionHelper, $this->getApplication()->getKernel(), $this->getContainer());
     $inputAssistant->askForPrefix(null, $foundBundle->getNamespace());
     // fields
     $input->setOption('fields', $this->addFields($input, $output, $questionHelper));
     // repository?
     $output->writeln('');
     $confirmationQuestion = new ConfirmationQuestion($questionHelper->getQuestion('Do you want to generate an empty repository class', $input->getOption('with-repository') ? 'yes' : 'no', '?'), $input->getOption('with-repository'));
     $withRepository = $questionHelper->ask($input, $output, $confirmationQuestion);
     $input->setOption('with-repository', $withRepository);
     // summary
     $output->writeln(array('', $this->getHelper('formatter')->formatBlock('Summary before generation', 'bg=blue;fg=white', true), '', sprintf("You are going to generate a \"<info>%s:%s</info>\" Doctrine2 entity", $bundle, $entity), ''));
 }