Exemple #1
0
 public function getUserOptions(User $user)
 {
     $options = $user->getOptions();
     if (is_null($options)) {
         $options = new UserOptions();
         $options->setUser($user);
         $this->objectManager->persist($options);
         $user->setOptions($options);
         $this->objectManager->persist($user);
         $this->objectManager->flush();
     }
     return $options;
 }
 /**
  * @EXT\Route(
  *     "/user/options/edit/form",
  *     name="claro_user_options_edit_form"
  * )
  *
  * @EXT\Template("ClarolineCoreBundle:Tool\desktop\parameters:userOptionsEditForm.html.twig")
  * @EXT\ParamConverter("user", options={"authenticatedUser"=true})
  *
  * Displays the user options form page.
  *
  * @param \Claroline\CoreBundle\Entity\User $user
  * @return Response
  */
 public function desktopParametersUserOptionsEditFormAction(User $user)
 {
     $options = $user->getOptions();
     if (is_null($options)) {
         $options = new UserOptions();
         $options->setUser($user);
         $user->setOptions($options);
         $this->om->persist($options);
         $this->om->persist($user);
         $this->om->flush();
     }
     $form = $this->formFactory->create(new UserOptionsType(), $options);
     return array('form' => $form->createView(), 'options' => $options);
 }