src/Slashworks/AppBundle/Controller/NotificationCenterController.php
public function updateAction(Request $request)
        {

            try {
                $id = $this->getUser()->getId();

                /** @var User $oUser */
                $oUser = UserQuery::create()->findOneById($id);

                if ($oUser === null) {
                    throw $this->createNotFoundException('Unable to find User entity.');
                }

                $aPost = $request->request->get("form");


                $nbUpdatedRows = UserQuery::create()
                    ->filterById($id)
                    ->update(array('NotificationError' => isset($aPost['notification_error']), 'NotificationChange' => isset($aPost['notification_change'])));


                $aResult = array(
                    "success" => true,
                    "message" => $this->get("translator")->trans("notificationcenter.save.successful")
                );

            } catch (\Exception $e) {
                $aResult = array(
                    "success" => false,
                    "message" => $this->get("translator")->trans("notificationcenter.save.failed") . ":<br>" . $e->getMessage()
                );
            }

            $sResult  = json_encode($aResult);
            $response = new Response($sResult);
            $response->headers->set('Content-Type', 'application/json');

            return $response;

        }
public function updateAction(Request $request)
        {

            try {
                $id = $this->getUser()->getId();

                /** @var User $oUser */
                $oUser = UserQuery::create()->findOneById($id);

                if ($oUser === null) {
                    throw $this->createNotFoundException('Unable to find User entity.');
                }

                $aPost = $request->request->get("form");


                $nbUpdatedRows = UserQuery::create()
                    ->filterById($id)
                    ->update(array('NotificationError' => isset($aPost['notification_error']), 'NotificationChange' => isset($aPost['notification_change'])));


                $aResult = array(
                    "success" => true,
                    "message" => $this->get("translator")->trans("notificationcenter.save.successful")
                );

            } catch (\Exception $e) {
                $aResult = array(
                    "success" => false,
                    "message" => $this->get("translator")->trans("notificationcenter.save.failed") . ":<br>" . $e->getMessage()
                );
            }

            $sResult  = json_encode($aResult);
            $response = new Response($sResult);
            $response->headers->set('Content-Type', 'application/json');

            return $response;

        }
public function updateAction ( Request $ request ) { try { $ id = $ this -> getUser ( ) -> getId ( ) ; /** @var User $oUser */ $ oUser = UserQuery :: create ( ) -> findOneById ( $ id ) ; if ( $ oUser === null ) { throw $ this -> createNotFoundException ( 'Unable to find User entity.' ) ; } $ aPost = $ request -> request -> get ( "form" ) ; $ nbUpdatedRows = UserQuery :: create ( ) -> filterById ( $ id ) -> update ( array ( 'NotificationError' => isset ( $ aPost [ 'notification_error' ] ) , 'NotificationChange' => isset ( $ aPost [ 'notification_change' ] ) ) ) ; $ aResult = array ( "success" => true , "message" => $ this -> get ( "translator" ) -> trans ( "notificationcenter.save.successful" ) ) ; } catch ( \ Exception $ e ) { $ aResult = array ( "success" => false , "message" => $ this -> get ( "translator" ) -> trans ( "notificationcenter.save.failed" ) . ":<br>" . $ e -> getMessage ( ) ) ; } $ sResult = json_encode ( $ aResult ) ; $ response = new Response ( $ sResult ) ; $ response -> headers -> set ( 'Content-Type' , 'application/json' ) ; return $ response ; }
Update notification settings

@param \Symfony\Component\HttpFoundation\Request $request

@return \Symfony\Component\HttpFoundation\Response
Update notification settings