Esempio n. 1
0
 /**
  * @Security("has_role('ROLE_USER')")
  * @Route("/user/change-email-settings", name="user-change-email-settings", options={"expose"=true})
  * @param Request $request
  * @return JsonResponse
  */
 public function saveEmailNotificationSettingsAction(Request $request)
 {
     $user_id = $this->getUser()->getId();
     $data = json_decode($request->getContent(), true);
     $data = (object) $data['settings'];
     /** @var EntityManager $em */
     $em = $this->getDoctrine()->getManager();
     try {
         User::changeEmailNotificationsSettings($em, $user_id, $data);
     } catch (\Exception $ex) {
         $from = "Class: User, function: changeEmailNotificationsSettings";
         $this->get('error_logger')->registerException($ex, $from);
         return new JsonResponse(-1);
     }
     return new JsonResponse(1);
 }