/** * Delete application * * @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 deleteApp(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); $clientApp->delete(); } catch (NotFoundHttpException $e) { $error = true; } return $app->json(['success' => !$error]); }