src/Action/TeamAction.php line 14

Open in your IDE?
  1. <?php
  2. declare(strict_types 1);
  3. namespace App\Action;
  4. use App\Domain\Repository\Interfaces\TextRepositoryInterface;
  5. use App\Responder\RedirectResponder;
  6. use App\Responder\TemplateResponder;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. use Symfony\Contracts\HttpClient\HttpClientInterface;
  9. use App\Domain\Repository\Interfaces\TeamRepositoryInterface;
  10. class TeamAction extends AbstractAction
  11. {
  12.     public function __construct(
  13.         TemplateResponder $templateResponder,
  14.         RedirectResponder $redirectResponder,
  15.         TeamRepositoryInterface $teamRepository
  16.     )
  17.     {
  18.         $this->templateResponder $templateResponder;
  19.         $this->redirectResponder $redirectResponder;
  20.         $this->teamRepository $teamRepository;
  21.     }
  22.     /**
  23.      * @Route("/equipe", name="team")
  24.      */
  25.     public function __invoke()
  26.     {
  27.         $teams $this->teamRepository->findTeams();
  28.         $teamCategories = [];
  29.         foreach ($teams as $team) {
  30.             if (!isset($teamCategories[$team['categoryName']])) {
  31.                 $teamCategories[$team['categoryName']] = [
  32.                     $team
  33.                 ];
  34.             } else {
  35.                 $teamCategories[$team['categoryName']][] = $team;
  36.             }
  37.         }
  38.         
  39.         return $this->templateResponder->__invoke('team.html.twig', [
  40.             'teamCategories' => $teamCategories
  41.         ]);
  42.     }
  43. }