code: public function createAction(Request $request)
      {
          $user = new User();
          $form = $this->createForm(UserType::class, $user);
          $form->bind($request);
  
          if ($form->isValid()) {
              $factory = $this->get('security.encoder_factory');
              $encoder = $factory->getEncoder($user);
              $user->setPassword($encoder->encodePassword($user->getPassword(), $user->getSalt()));
  
              $em = $this->getDoctrine()->getManager();
              $em->persist($user);
              $em->flush();
  
              $this->get('session')->getFlashBag()->set('success', 'The user has been created.');
  
              return $this->redirect($this->generateUrl('orkestra_user_show', array('id' => $user->getId())));
          }
  
          return array(
              'user' => $user,
              'form' => $form->createView()
          );
      }
docs: Creates a new User entity.
  
  @Route("/create", name="orkestra_user_create")
  @Method("post")
  @Template("OrkestraApplicationBundle:User:new.html.twig")
  @Secure(roles="ROLE_USER_WRITE")