feat: shows popular movies
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Download\Framework\Repository\DownloadRepository;
|
||||
use App\Tmdb\Tmdb;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
@@ -11,6 +12,7 @@ final class IndexController extends AbstractController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly DownloadRepository $downloadRepository,
|
||||
private readonly Tmdb $tmdb,
|
||||
) {}
|
||||
|
||||
#[Route('/', name: 'app_index')]
|
||||
@@ -18,7 +20,8 @@ final class IndexController extends AbstractController
|
||||
{
|
||||
return $this->render('index/index.html.twig', [
|
||||
'active_downloads' => [],
|
||||
'recent_downloads' => $this->downloadRepository->latest(5)
|
||||
'recent_downloads' => $this->downloadRepository->latest(5),
|
||||
'popular_movies' => $this->tmdb->popularMovies(1, 6),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,12 +94,18 @@ class Tmdb
|
||||
$this->tvRepository = new TvRepository($this->client);
|
||||
}
|
||||
|
||||
public function popularMovies(int $page = 1)
|
||||
public function popularMovies(int $page = 1, ?int $limit = null)
|
||||
{
|
||||
$movies = $this->movieRepository->getPopular(['page' => $page]);
|
||||
|
||||
foreach ($movies as $movie) {
|
||||
$this->parseResult($movie);
|
||||
$movies = $movies->map(function ($movie) use ($movies) {
|
||||
return $this->parseResult($movies[$movie], "movie");
|
||||
});
|
||||
|
||||
$movies = array_values($movies->toArray());
|
||||
|
||||
if (null !== $limit) {
|
||||
$movies = array_slice($movies, 0, $limit);
|
||||
}
|
||||
|
||||
return $movies;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<div{{ attributes }}>
|
||||
<img src="{{ image }}" class="w-40 rounded-md" />
|
||||
<h3 class="text-center text-gray-50 text-extrabold">{{ title }}</h3>
|
||||
<h3 class="text-center text-gray-50 max-w-[16ch] text-extrabold">{{ title }}</h3>
|
||||
</div>
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
</tr>
|
||||
{% endfor %}
|
||||
<tr class="bg-blue-400">
|
||||
<td class="px-6 py-3 whitespace-nowrap text-xs uppercase text-center col-span-2 font-medium text-gray-800 dark:text-stone-800" colspan="2">
|
||||
<td class="px-6 py-3 whitespace-nowrap text-xs uppercase text-center col-span-2 font-medium text-rose-400 dark:text-stone-800" colspan="2">
|
||||
<a href="#">View all downloads</a>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -91,12 +91,9 @@
|
||||
</div>
|
||||
<div class="">
|
||||
<twig:Card title="Popular Movies" contentClass="flex flex-row justify-between w-full">
|
||||
<twig:Poster imdbId="" title="A Working Man" description="" image="https://image.tmdb.org/t/p/w500/xUkUZ8eOnrOnnJAfusZUqKYZiDu.jpg" year="" />
|
||||
<twig:Poster imdbId="" title="In the Lost Lands" description="" image="https://image.tmdb.org/t/p/w500/iHf6bXPghWB6gT8kFkL1zo00x6X.jpg" year="" />
|
||||
<twig:Poster imdbId="" title="A Minecraft Movie" description="" image="https://image.tmdb.org/t/p/w500/yFHHfHcUgGAxziP1C3lLt0q2T4s.jpg" year="" />
|
||||
<twig:Poster imdbId="" title="G20" description="" image="https://image.tmdb.org/t/p/w500/wv6oWAleCJZUk5htrGg413t3GCy.jpg" year="" />
|
||||
<twig:Poster imdbId="" title="Novocaine" description="" image="https://image.tmdb.org/t/p/w500/xmMHGz9dVRaMY6rRAlEX4W0Wdhm.jpg" year="" />
|
||||
<twig:Poster imdbId="" title="Gunslingers" description="" image="https://image.tmdb.org/t/p/w500/O7REXWPANWXvX2jhQydHjAq2DV.jpg" year="" />
|
||||
{% for movie in popular_movies %}
|
||||
<twig:Poster imdbId="" title="{{ movie.title }}" description="{{ movie.description }}" image="{{ movie.poster }}" year="{{ movie.year }}" />
|
||||
{% endfor %}
|
||||
</twig:Card>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user