/**
  * 
  * @return \Symfony\Component\Form\Form 
  */
 public function createForm()
 {
     $type = $this->userDiscriminator->getFormType($this->type);
     $name = $this->userDiscriminator->getFormName($this->type);
     $validationGroups = $this->userDiscriminator->getFormValidationGroups($this->type);
     if (array_key_exists($name, $this->forms)) {
         return $this->forms[$name];
     }
     $form = $this->formFactory->createNamed($name, $type, null, array('validation_groups' => $validationGroups));
     $this->forms[$name] = $form;
     return $form;
 }
 /**
  * @param string $class
  * @return RedirectResponse
  */
 public function edit($class)
 {
     $this->userDiscriminator->setClass($class);
     $this->controller->setContainer($this->container);
     $result = $this->controller->editAction($this->container->get('request'));
     if ($result instanceof RedirectResponse) {
         return $this->controller->redirect($this->controller->get('request')->getRequestUri());
     }
     $template = $this->userDiscriminator->getTemplate('profile');
     if (is_null($template)) {
         $template = 'FOSUserBundle:Profile:edit.html.twig';
     }
     $form = $this->formFactory->createForm();
     return $this->container->get('templating')->renderResponse($template, array('form' => $form->createView()));
 }
 /**
  * {@inheritDoc}
  */
 protected function findConflictualUsers($value, array $fields)
 {
     $classes = $this->userDiscriminator->getClasses();
     foreach ($classes as $class) {
         $repo = $this->om->getRepository($class);
         $users = $repo->findBy($this->getCriteria($value, $fields));
         if (count($users) > 0) {
             return $users;
         }
     }
     return array();
 }
 protected function discriminate($user)
 {
     $class = ClassUtils::getClass($user);
     $this->userDiscriminator->setClass($class, true);
 }