Commit 53edeef2 authored by Moreau Elise's avatar Moreau Elise
Browse files

update routes

parent 39cc5abb
......@@ -27,12 +27,12 @@ use App\Application\Actions\Search\CreateDB;
use App\Application\Actions\Message\CreateMessageAction;
use App\Application\Actions\Message\GroupMessagesListAction;
use App\Application\Actions\User\ContaminatedUsersInGroup;
use App\Application\Actions\User\NearContaminatedUsers;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Server\RequestHandlerInterface as RequestHandler;
use Slim\App;
use Slim\Interfaces\RouteCollectorProxyInterface as Group;
......@@ -49,6 +49,13 @@ return function (App $app) {
}
);
$app->add(function (Request $request, RequestHandler $handler) {
$messages = $this->get(Messages::class)->getMessages();
$environment = $this->get(Twig::class)->getEnvironment();
$environment->addGlobal('flashMessages', $messages);
return $handler->handle($request);
});
$app->get('/', function (Request $request, Response $response) {
return $this->get(Twig::class)->render($response, "/home/home.twig", []);
}
......@@ -59,7 +66,6 @@ return function (App $app) {
}
);
$app->get('/createdb', CreateDB::class);
$app->group('/search', function (Group $group) {
......@@ -77,12 +83,10 @@ return function (App $app) {
->withHeader('Location', '/account')
->withStatus(302);
}
$message = $this->get(Messages::class)->getFirstMessage('creation');
return $this->get(Twig::class)->render($response, "/user/log_in.twig", ["message" => $message]);
return $this->get(Twig::class)->render($response, "/user/log_in.twig");
});
$group->post('', LogInUserAction::class);
$group->post('', LogInUserAction::class);
}
);
......@@ -90,7 +94,7 @@ return function (App $app) {
session_unset();
return $response
->withHeader('Location', '/')
->withStatus(302);
->withStatus(302);
}
);
......@@ -115,8 +119,9 @@ return function (App $app) {
'/groups', function (Group $group) {
$group->get('/create', function (Request $request, Response $response) {
return $this->get(Twig::class)->render($response, "/group/create_group.twig", []);
});
});
$group->get('', ListGroupsAction::class);
$group->get('/{id}', ViewGroupAction::class);
$group->post('', CreateGroupAction::class);
$group->post('/{id}/delete', DeleteGroupAction::class);
$group->get('/{id}/modify', ViewModifyGroupForm::class);
......@@ -126,7 +131,6 @@ return function (App $app) {
$group->post('/{id}/users/{user_id}/delete', DeleteUserGroupAction::class);
$group->get('/{id}/messages', GroupMessagesListAction::class);
$group->post('/{id}/messages', CreateMessageAction::class);
$group->get('/{id}', ViewGroupAction::class);
}
);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment