62 lines
1.9 KiB
PHP
62 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Base\Framework\Controller;
|
|
|
|
use App\Monitor\Action\Command\MonitorTvShowCommand;
|
|
use App\Monitor\Action\Handler\MonitorTvShowHandler;
|
|
use App\Tmdb\Tmdb;
|
|
use App\User\Framework\Entity\User;
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Symfony\Component\Mailer\MailerInterface;
|
|
use Symfony\Component\Mime\Email;
|
|
use Symfony\Component\Routing\Attribute\Route;
|
|
|
|
final class IndexController extends AbstractController
|
|
{
|
|
public function __construct(
|
|
private readonly Tmdb $tmdb,
|
|
private readonly MonitorTvShowHandler $monitorTvShowHandler,
|
|
) {}
|
|
|
|
#[Route('/', name: 'app_index')]
|
|
public function index(Request $request): Response
|
|
{
|
|
/** @var User $user */
|
|
$user = $this->getUser();
|
|
return $this->render('index/index.html.twig', [
|
|
'active_downloads' => $this->getUser()->getActiveDownloads(),
|
|
'recent_downloads' => $this->getUser()->getDownloads(),
|
|
'popular_movies' => $this->tmdb->popularMovies(1, 6),
|
|
'popular_tvshows' => $this->tmdb->popularTvShows(1, 6),
|
|
]);
|
|
}
|
|
|
|
#[Route('/email')]
|
|
public function sendEmail(MailerInterface $mailer): Response
|
|
{
|
|
$email = (new Email())
|
|
->to('brock@caldwell.digital')
|
|
->subject('Time for Symfony Mailer!')
|
|
->text('Sending emails is fun again!')
|
|
->html('<p>See Twig integration for better HTML integration!</p>');
|
|
|
|
$mailer->send($email);
|
|
|
|
return $this->json([
|
|
'success' => true,
|
|
'message' => 'Email sent!'
|
|
]);
|
|
}
|
|
|
|
#[Route('/test')]
|
|
public function monitorTvShow(): Response
|
|
{
|
|
$this->monitorTvShowHandler->handle(new MonitorTvShowCommand(96));
|
|
return $this->json([
|
|
'Success' => 'Monitor added'
|
|
]);
|
|
}
|
|
}
|