|
|
|
@ -13,15 +13,12 @@ use \Twig\Environment;
|
|
|
|
|
class TeamController
|
|
|
|
|
{
|
|
|
|
|
private TeamModel $model;
|
|
|
|
|
private Environment $twig;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param TeamModel $model
|
|
|
|
|
* @param Environment $twig
|
|
|
|
|
*/
|
|
|
|
|
public function __construct(TeamModel $model, Environment $twig) {
|
|
|
|
|
public function __construct(TeamModel $model) {
|
|
|
|
|
$this->model = $model;
|
|
|
|
|
$this->twig = $twig;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function displaySubmitTeam() : HttpResponse {
|
|
|
|
@ -29,7 +26,6 @@ class TeamController
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function submitTeam(array $request): HttpResponse {
|
|
|
|
|
|
|
|
|
|
$errors = [];
|
|
|
|
|
|
|
|
|
|
$request = HttpRequest::from($request, $errors, [
|
|
|
|
@ -47,7 +43,7 @@ class TeamController
|
|
|
|
|
}
|
|
|
|
|
return ViewHttpResponse::twig('insert_team.html.twig', ['bad_fields' => $badFields]);
|
|
|
|
|
}
|
|
|
|
|
return $this->displayTeam($this->model->createTeam($request['name'], $request['picture'], $request['mainColor'], $request['secondColor']));
|
|
|
|
|
return $this->getTeam($this->model->createTeam($request['name'], $request['picture'], $request['mainColor'], $request['secondColor']));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function displayListTeamByName(): HttpResponse {
|
|
|
|
@ -74,7 +70,7 @@ class TeamController
|
|
|
|
|
return ViewHttpResponse::twig('display_teams.html.twig', ['teams' => $results]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function displayTeam(int $id): HttpResponse {
|
|
|
|
|
public function getTeam(int $id): HttpResponse {
|
|
|
|
|
$result = $this->model->displayTeam($id);
|
|
|
|
|
return ViewHttpResponse::twig('display_team.html.twig', ['team' => $result]);
|
|
|
|
|
}
|
|
|
|
|