src/Controller/HomeController.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Activity;
  4. use App\Message\Event\CompileActivityEvent;
  5. use App\Message\Event\ReloadActivityEvent;
  6. use App\Message\Event\SyncActivityEvent;
  7. use App\Repository\ActivityRepository;
  8. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\Messenger\MessageBusInterface;
  11. use Symfony\Component\Routing\Annotation\Route;
  12. final class HomeController extends BaseController
  13. {
  14.     #[Route('/''app_home_entry')]
  15.     public function entry(): Response
  16.     {
  17.         return $this->redirectToRoute('app_home_dashboard');
  18.     }
  19.     #[Route('/home/dashboard''app_home_dashboard')]
  20.     public function dashboard(): Response
  21.     {
  22.         return $this->render('home/dashboard.html.twig');
  23.     }
  24.     #[Route('/home/activities''app_home_activities')]
  25.     public function activities(ActivityRepository $activityRepository): Response
  26.     {
  27.         return $this->render('home/activities.html.twig', [
  28.             'activities' => $this->getUser()->getActivities(),
  29.         ]);
  30.     }
  31.     #[Route('/home/activities/{activity}/rebuild''app_home_activities_rebuild')]
  32.     public function activitiesRebuild(Activity $activityMessageBusInterface $messageBus): Response
  33.     {
  34.         $messageBus->dispatch(new CompileActivityEvent($activity));
  35.         return $this->redirectToRoute('app_home_activities');
  36.     }
  37.     #[Route('/home/activities/{activity}/reload''app_home_activities_reload')]
  38.     public function activitiesReload(Activity $activityMessageBusInterface $messageBus): Response
  39.     {
  40.         $messageBus->dispatch(new ReloadActivityEvent($activity));
  41.         return $this->redirectToRoute('app_home_activities');
  42.     }
  43.     #[Route('/home/activities/{activity}/sync''app_home_activities_sync')]
  44.     public function activitiesSync(Activity $activityMessageBusInterface $messageBus): Response
  45.     {
  46.         $messageBus->dispatch(new SyncActivityEvent($activity));
  47.         return $this->redirectToRoute('app_home_activities');
  48.     }
  49.     #[Route('/home/activities/{activity}/delete''app_home_activities_delete')]
  50.     public function activitiesDelete(Activity $activityMessageBusInterface $messageBus): Response
  51.     {
  52.         return $this->redirectToRoute('app_home_activities');
  53.     }
  54. }