/**
  * @Route("/entity", name="_generator_entity")
  * @Template()
  */
 public function generateAction()
 {
     $request = $this->get('request');
     $entity = new Entity();
     $form = $this->get('form.factory')->create(new GenerateEntityType(), $entity);
     if ('POST' == $request->getMethod()) {
         $form->bindRequest($request);
         if ($form->isValid()) {
             $fields = array();
             foreach ($entity->fields as $field) {
                 $fields[$field->fieldName] = array('fieldName' => $field->fieldName, 'type' => $field->type);
                 if ($field->type == 'string') {
                     $fields[$field->fieldName]['length'] = $field->length;
                 }
             }
             $generator = new DoctrineEntityGenerator($this->get('filesystem'), $this->get('doctrine'));
             $generator->generate($this->get('kernel')->getBundle($entity->bundle), $entity->name, $entity->format, $fields, $entity->with_repository);
             $request->getSession()->setFlash('notice', sprintf("Your entity '%s' has been generated.", $entity->name));
             return new RedirectResponse($this->generateUrl('_generator'));
         }
     }
     return array('form' => $form->createView());
 }
 protected function getGenerator()
 {
     $generator = new DoctrineEntityGenerator($this->filesystem, $this->getRegistry());
     $generator->setSkeletonDirs(__DIR__ . '/../../Resources/skeleton');
     return $generator;
 }