<?php
namespace App\Controller;
use App\Entity\Activity;
use App\Message\Event\CompileActivityEvent;
use App\Message\Event\ReloadActivityEvent;
use App\Message\Event\SyncActivityEvent;
use App\Repository\ActivityRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Routing\Annotation\Route;
final class HomeController extends BaseController
{
#[Route('/', 'app_home_entry')]
public function entry(): Response
{
return $this->redirectToRoute('app_home_dashboard');
}
#[Route('/home/dashboard', 'app_home_dashboard')]
public function dashboard(): Response
{
return $this->render('home/dashboard.html.twig');
}
#[Route('/home/activities', 'app_home_activities')]
public function activities(ActivityRepository $activityRepository): Response
{
return $this->render('home/activities.html.twig', [
'activities' => $this->getUser()->getActivities(),
]);
}
#[Route('/home/activities/{activity}/rebuild', 'app_home_activities_rebuild')]
public function activitiesRebuild(Activity $activity, MessageBusInterface $messageBus): Response
{
$messageBus->dispatch(new CompileActivityEvent($activity));
return $this->redirectToRoute('app_home_activities');
}
#[Route('/home/activities/{activity}/reload', 'app_home_activities_reload')]
public function activitiesReload(Activity $activity, MessageBusInterface $messageBus): Response
{
$messageBus->dispatch(new ReloadActivityEvent($activity));
return $this->redirectToRoute('app_home_activities');
}
#[Route('/home/activities/{activity}/sync', 'app_home_activities_sync')]
public function activitiesSync(Activity $activity, MessageBusInterface $messageBus): Response
{
$messageBus->dispatch(new SyncActivityEvent($activity));
return $this->redirectToRoute('app_home_activities');
}
#[Route('/home/activities/{activity}/delete', 'app_home_activities_delete')]
public function activitiesDelete(Activity $activity, MessageBusInterface $messageBus): Response
{
return $this->redirectToRoute('app_home_activities');
}
}