Beispiel #1
0
    $response = new Response($content, 200);
    $response->send();
});
$app->get('/statuses/(\\d+)', function (Request $request, $id) use($app, $statusFinder) {
    if (!Verification::checkInteger($id)) {
        $response = new Response("Error with the object ID", 400);
        $response->send();
        return;
    }
    $status = $statusFinder->findOneById($id);
    if (!isset($status)) {
        $response = new Response("Object doesn't exist", 416);
        $response->send();
        return;
    }
    if (Request::guessBestFormat() == 'json') {
        $response = new Response(json_encode($status), 200);
        $response->send();
        return;
    }
    $content = $app->render("unStatus.php", array('status' => $status));
    $response = new Response($content, 200);
    $response->send();
});
$app->get('/statusesForm', function (Request $request) use($app) {
    return $app->render("statusesForm.php", array('user' => $_SESSION['login'], 'erreur' => '', 'message' => ''));
});
$app->post('/statuses', function (Request $request) use($app, $statusMapper) {
    $message = htmlspecialchars($request->getParameter('message'));
    $user = htmlspecialchars($request->getParameter('username'));
    if (!isset($user) || !isset($message)) {