/**
  * {@inheritdoc}
  */
 protected function doExecute()
 {
     $this->assistant->writeSection('PagePart generation');
     $this->createGenerator()->generate($this->bundle, $this->pagepartName, $this->prefix, $this->fields, $this->sections, $this->behatTest);
     $this->assistant->writeSection('PagePart successfully created', 'bg=green;fg=black');
     $this->assistant->writeLine(array('Make sure you update your database first before you test the pagepart:', '    Directly update your database:          <comment>app/console doctrine:schema:update --force</comment>', '    Create a Doctrine migration and run it: <comment>app/console doctrine:migrations:diff && app/console doctrine:migrations:migrate</comment>', $this->behatTest ? 'A new behat test is created, to run it: <comment>bin/behat --tags \'@' . $this->pagepartName . '\' @' . $this->bundle->getName() . '</comment>' : ''));
 }
 /**
  * @param QuestionHelper $question
  * @param InputInterface $input
  * @param OutputInterface $output
  * @param BundleInterface $bundle
  * @param $metadata
  * @param $entity
  * @param $filename
  */
 protected function generateAdmin(QuestionHelper $question, InputInterface $input, OutputInterface $output, BundleInterface $bundle, $metadata, $entity, $filename)
 {
     $auto = true;
     if ($input->isInteractive()) {
         $auto = $question->ask($input, $output, new ConfirmationQuestion('Confirm automatic generation of the Admin service?', false));
     }
     if ($auto) {
         $group = ucfirst(str_replace('_', ' ', Container::underscore(substr($bundle->getName(), 0, -6))));
         $label = $entity;
         $translationDomain = 'Sonata';
         $groupQuestion = new Question('Group for the admin service: ', $group);
         $groupQuestion->setValidator(array('Sensio\\Bundle\\GeneratorBundle\\Command\\Validators', 'validateEntityName'));
         $groupQuestion->setAutocompleterValues([$group]);
         $group = $question->ask($input, $output, $groupQuestion);
         $labelQuestion = new Question('Label for the admin service: ', $label);
         $labelQuestion->setValidator(array('Sensio\\Bundle\\GeneratorBundle\\Command\\Validators', 'validateEntityName'));
         $labelQuestion->setAutocompleterValues([$label]);
         $label = $question->ask($input, $output, $labelQuestion);
         $translationDomainQuestion = new Question('Translation domain for the admin service: ', $translationDomain);
         $translationDomainQuestion->setAutocompleterValues([$translationDomain]);
         $translationDomain = $question->ask($input, $output, $labelQuestion);
         $output->write('Creating the service: ');
         $this->getContainer()->get('filesystem')->mkdir($bundle->getPath() . '/Resources/config/');
         $admin = new AdminManipulator($bundle->getPath() . '/Resources/config/' . $filename);
         try {
             $ret = $auto ? $admin->addResource($bundle, $entity, $group, $label, $translationDomain) : false;
         } catch (\RuntimeException $exc) {
             $ret = false;
         }
         if ($ret) {
             $output->write('Creating the Admin class: ');
             $generator = $this->getGenerator($bundle);
             $generator->generateAdminClass($metadata[0], $input->getOption('overwrite'));
         }
     }
 }