/**
  * 
  * @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, get_class($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()));
 }
 /**
  * 
  * @param string $class
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function register($class)
 {
     $this->userDiscriminator->setClass($class);
     $this->controller->setContainer($this->container);
     $result = $this->controller->registerAction($this->container->get('request'));
     if ($result instanceof RedirectResponse) {
         return $result;
     }
     $template = $this->userDiscriminator->getTemplate('registration');
     if (is_null($template)) {
         $engine = $this->container->getParameter('fos_user.template.engine');
         $template = 'FOSUserBundle:Registration:register.html.' . $engine;
     }
     $form = $this->formFactory->createForm();
     return $this->container->get('templating')->renderResponse($template, array('form' => $form->createView()));
 }
 /**
  * @param string $class
  * @return RedirectResponse
  */
 public function show($class)
 {
     $user = $this->getUser();
     if (!is_object($user) || !$user instanceof UserInterface) {
         throw new AccessDeniedException('This user does not have access to this section.');
     }
     $this->userDiscriminator->setClass($class);
     $this->controller->setContainer($this->container);
     $result = $this->controller->showAction($this->getRequest());
     if ($result instanceof RedirectResponse) {
         return $this->controller->redirect($this->getRequest()->getRequestUri());
     }
     $template = $this->userDiscriminator->getTemplate('profile');
     if (is_null($template)) {
         $template = 'FOSUserBundle:Profile:show.html.twig';
     }
     return $this->container->get('templating')->renderResponse($template, array('user' => $user));
 }
 /**
  * {@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);
 }
 protected function discriminate($user)
 {
     $this->userDiscriminator->setClass(get_class($user), true);
 }