/** * Change application callback * * @param Application $app A Silex application where the controller is mounted on * @param Request $request The current request * @param integer $id The application id * @return JsonResponse */ public function renewAppCallback(Application $app, Request $request, $id) { if (!$request->isXmlHttpRequest() || !array_key_exists($request->getMimeType('json'), array_flip($request->getAcceptableContentTypes()))) { $app->abort(400, 'Bad request format, only JSON is allowed'); } $error = false; try { $clientApp = new \API_OAuth2_Application($app, $id); if (null !== $request->request->get("callback")) { $clientApp->set_redirect_uri($request->request->get("callback")); } else { $error = true; } } catch (NotFoundHttpException $e) { $error = true; } return $app->json(['success' => !$error]); }