public function createChatUser(User $user, $username, $password) { $chatUser = new ChatUser(); $chatUser->setUser($user); $chatUser->setChatUsername($username); $chatUser->setChatPassword($password); $this->om->persist($chatUser); $this->om->flush(); }
/** * @EXT\Route( * "/admin/chat/user/{chatUser}/edit", * name="claro_chat_user_edit", * options={"expose"=true} * ) * @EXT\ParamConverter("authenticatedUser", options={"authenticatedUser" = true}) * @EXT\Template("ClarolineChatBundle:AdminChat:chatUserEditModalForm.html.twig") */ public function chatUserEditAction(ChatUser $chatUser) { $options = $chatUser->getOptions(); $color = isset($options['color']) ? $options['color'] : null; $form = $this->formFactory->create(new ChatUserEditionType($color)); $form->handleRequest($this->request); if ($form->isValid()) { $newColor = $form->get('color')->getData(); if (is_null($options)) { $options = array('color' => $newColor); } else { $options['color'] = $newColor; } $chatUser->setOptions($options); $this->chatManager->persistChatUser($chatUser); return new JsonResponse('success', 200); } else { return array('form' => $form->createView()); } }