/** * @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} */ public function findUserBy(array $criteria) { $classes = $this->userDiscriminator->getClasses(); foreach ($classes as $class) { $repo = $this->om->getRepository($class); if (!$repo) { throw new \LogicException(sprintf('Repository "%s" not found', $class)); } // Some models does not have the property associated to the criteria try { $user = $repo->findOneBy($criteria); } catch (ORMException $e) { $user = null; } if ($user) { $this->userDiscriminator->setClass($class); return $user; } } return null; }
protected function discriminate($user) { $class = ClassUtils::getClass($user); $this->userDiscriminator->setClass($class, true); }
protected function discriminate($user) { $this->userDiscriminator->setClass(get_class($user), true); }