get('session')->save(); $this->get('net15.restifier.dispatch')->map('GET',$this,'getValue',$var); $this->get('net15.restifier.dispatch')->map('POST',$this,'setValue',$var); return $this->get('net15.restifier.dispatch')->exec(); } /** * api function * * response : string JSON * @param $var * @return JsonResponse */ public function getValue($var){ $json = array(); $json['state'] = null; /** * @var CustomUserInterface $user */ $user = $this->getUser(); try { $json['state'] = $this->get('net15.user.manager')->getValue($user, $var); } catch (FatalErrorException $e){ throw $this->createNotFoundException('This setting does not exist.'); } return new JsonResponse($json); } public function setValue($var){ $json = array(); $json['return'] = false; $value =$this->get('net15.restifier.dispatch')->getContentValue('value',null); if(!isset($value)) return new JsonResponse($json); /** * @var CustomUserInterface $user */ $user = $this->getUser(); try { $json['return'] = $this->get('net15.user.manager')->setValue($user, $var, $value); } catch (FatalErrorException $e){ throw $this->createNotFoundException('This setting does not exist.'); } return new JsonResponse($json); } }