2026-01-13 12:58:53 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace App\Controller;
|
|
|
|
|
|
|
|
|
|
use App\Gateway\TMDBGateway;
|
2026-01-13 20:26:00 +00:00
|
|
|
use App\Model\Ltbxd\LtbxdMovie;
|
2026-01-13 12:58:53 +00:00
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
|
|
|
use Symfony\Component\HttpClient\Exception\ClientException;
|
|
|
|
|
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-13 20:26:00 +00:00
|
|
|
private readonly TMDBGateway $TMDBGateway, private readonly SerializerInterface $serializer,
|
|
|
|
|
) {}
|
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-13 20:26:00 +00:00
|
|
|
$file = file_get_contents('files/watched.csv');
|
|
|
|
|
$ltbxdMovies = $this->serializer->deserialize($file, LtbxdMovie::class.'[]', 'csv');
|
|
|
|
|
/** @var LtbxdMovie $ltbxdMovie */
|
|
|
|
|
$films = [];
|
|
|
|
|
foreach ($ltbxdMovies as $ltbxdMovie) {
|
|
|
|
|
// Search movie on TMDB
|
|
|
|
|
$searchResult = $this->TMDBGateway->searchMovie($ltbxdMovie->getName());
|
|
|
|
|
$films[] = $searchResult->getResults()[0];
|
2026-01-13 12:58:53 +00:00
|
|
|
}
|
2026-01-13 20:26:00 +00:00
|
|
|
dd($films);
|
2026-01-13 12:58:53 +00:00
|
|
|
|
|
|
|
|
return $this->render('homepage/index.html.twig');
|
|
|
|
|
}
|
|
|
|
|
}
|