コード例 #1
0
 /**
  * @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()));
 }
コード例 #2
0
 /**
  * {@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;
 }
コード例 #3
0
 protected function discriminate($user)
 {
     $class = ClassUtils::getClass($user);
     $this->userDiscriminator->setClass($class, true);
 }