2026-01-13 12:58:53 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace App\Controller;
|
|
|
|
|
|
|
|
|
|
use App\Gateway\TMDBGateway;
|
2026-01-15 13:01:45 +00:00
|
|
|
use App\Repository\MovieRepository;
|
2026-01-13 12:58:53 +00:00
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
|
use Symfony\Component\Routing\Attribute\Route;
|
2026-01-13 20:26:00 +00:00
|
|
|
use Symfony\Component\Serializer\SerializerInterface;
|
2026-01-13 12:58:53 +00:00
|
|
|
|
|
|
|
|
class HomepageController extends AbstractController
|
|
|
|
|
{
|
|
|
|
|
public function __construct(
|
2026-01-15 13:01:45 +00:00
|
|
|
private readonly MovieRepository $movieRepository,
|
|
|
|
|
private readonly TMDBGateway $TMDBGateway,
|
2026-01-13 20:26:00 +00:00
|
|
|
) {}
|
2026-01-13 12:58:53 +00:00
|
|
|
|
|
|
|
|
#[Route('/')]
|
2026-01-13 20:26:00 +00:00
|
|
|
public function index(SerializerInterface $serializer): Response
|
2026-01-13 12:58:53 +00:00
|
|
|
{
|
2026-01-15 13:01:45 +00:00
|
|
|
$movie = $this->movieRepository->findOneBy([]);
|
|
|
|
|
$creditsContext = $this->TMDBGateway->getMovieCredits($movie->getTmdbId());
|
|
|
|
|
$cast = $creditsContext->cast;
|
|
|
|
|
$actors = [];
|
|
|
|
|
foreach ($cast as $actor) {
|
|
|
|
|
if (2 <= $actor->popularity) {
|
|
|
|
|
$actors[] = $actor;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
dd($actors);
|
2026-01-13 12:58:53 +00:00
|
|
|
|
|
|
|
|
return $this->render('homepage/index.html.twig');
|
|
|
|
|
}
|
|
|
|
|
}
|