<?php
declare(strict_types = 1);
namespace App\Action;
use App\Domain\Repository\Interfaces\TextRepositoryInterface;
use App\Responder\RedirectResponder;
use App\Responder\TemplateResponder;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use App\Domain\Repository\Interfaces\TeamRepositoryInterface;
class TeamAction extends AbstractAction
{
public function __construct(
TemplateResponder $templateResponder,
RedirectResponder $redirectResponder,
TeamRepositoryInterface $teamRepository
)
{
$this->templateResponder = $templateResponder;
$this->redirectResponder = $redirectResponder;
$this->teamRepository = $teamRepository;
}
/**
* @Route("/equipe", name="team")
*/
public function __invoke()
{
$teams = $this->teamRepository->findTeams();
$teamCategories = [];
foreach ($teams as $team) {
if (!isset($teamCategories[$team['categoryName']])) {
$teamCategories[$team['categoryName']] = [
$team
];
} else {
$teamCategories[$team['categoryName']][] = $team;
}
}
return $this->templateResponder->__invoke('team.html.twig', [
'teamCategories' => $teamCategories
]);
}
}