Shhhht! The crew is at work 🤫

Discover the baksla.sh team members while they're working

💡 Click on a member to discover their full profile.

@@ -10,7 +10,7 @@
10
use App\Team\Infrastructure\InMemory\InMemoryMemberRepository;
11
use Symfony\Component\HttpFoundation\Exception\NotFoundHttpException;
12
use Symfony\Component\HttpFoundation\Request;
13
use Symfony\Component\HttpFoundation\Response;
14
use Symfony\Component\HttpKernel\Attribute\AsController;
15
use Symfony\Component\Routing\Attribute\Route;
16
use Twig\Environment;
Hugo Alliaume

Hugo Alliaume

  • UX Core Team
Could we alias this import to Twig to make it a little more understandable?
Félix Eymonot

Félix Eymonot

  • Certified (advanced)
Another idea could be to extend the AbstractController and use the render method, WDYT?
17
18
#[AsController]
19
final readonly class ViewTeam
20
{
21
    public function __construct(
22
        private Environment $twig,
23
        private InMemoryMemberRepository $memberRepository,
Robin Chalas

Robin Chalas

  • CEO
  • Core Team
Always use interfaces instead of concrete implementations.
It takes advantage of polymorphism and reduce coupling between classes.
Mathias Arlaud

Mathias Arlaud

  • COO
  • Core Team
  • Certified (expert)
👍 Plus, the MemberRepository belongs to the "Domain" layer.
We must rely as much as possible on code from that layer.
Jérémy Romey

Jérémy Romey

  • Certified (advanced)
If you want to have a specific implementation, you can use the "Autowire" attribute.
24
    ) {
25
    }
26
27
    #[Route(name: 'app_team', path: '/team')]
28
    public function __invoke(Request $request): Response
29
    {
30
        return new Response();
30
        if ('GET' !== $request->getMethod()) {
31
            throw new NotFoundHttpException();
Arnaud De Abreu

Arnaud De Abreu

  • Certified
While it works, it's not the best way to achieve that. Instead, you should leverage #[Route(methods: ['GET'])].
Valmont Pehaut Pietri

Valmont Pehaut Pietri

He's right, while it makes it declarative, it allows us to see that only GET is allowed when using debug:router.
32
        }
33
34
        return new Response($this->twig->render('pages/team/index.html.twig', [
35
            'members' => $this->memberRepository->findAll(),
Jules Pietri

Jules Pietri

  • Certified (expert)
  • Former Core Team
Maybe we could get a paginated result instead?
Yazid Hassani

Yazid Hassani

AFAIK, bakslash won't have enough members to need pagination any time soon 😉
36
        ]);
36
Jules Pietri

Jules Pietri

  • Certified (expert)
  • Former Core Team
Extra blank line 👀
30
    }

Reviewers (9)

Arnaud De Abreu Félix Eymonot Hugo Alliaume Jérémy Romey Jules Pietri Mathias Arlaud Robin Chalas Valmont Pehaut Pietri Yazid Hassani

Reviewers (9)

  • Arnaud De Abreu

    Arnaud De Abreu

  • Félix Eymonot

    Félix Eymonot

  • Hugo Alliaume

    Hugo Alliaume

  • Jérémy Romey

    Jérémy Romey

  • Jules Pietri

    Jules Pietri

  • Mathias Arlaud

    Mathias Arlaud

  • Robin Chalas

    Robin Chalas

  • Valmont Pehaut Pietri

    Valmont Pehaut Pietri

  • Yazid Hassani

    Yazid Hassani