src/Controller/Views/DashboardController.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Views;
  3. use App\Enum\SettingsKey;
  4. use App\Service\CalendarService;
  5. use App\Service\KeyService;
  6. use App\Service\MessageService;
  7. use App\Service\SerializerService;
  8. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\Routing\Annotation\Route;
  11. class DashboardController extends AbstractController{
  12.     #[Route('/', methods: ['GET'])]
  13.     public function index(MessageService $messageService, KeyService $keyService, CalendarService $calendarService): Response
  14.     {
  15.         $googleAt=$keyService->getValue(SettingsKey::GOOGLE_O2AUTH, true, true);
  16.         try {
  17.             if(!empty($googleAt)) $calendarService->fetchFromGoogle();
  18.         } catch(\Exception $ex){
  19.             $googleAt="";
  20.         }
  21.         $messageSummary=$messageService->getTodaySummary();
  22.         return $this->render('views/dashboard/index.html.twig', [
  23.             'google_at'=>$googleAt,
  24.             'meta_at'=>$keyService->getValue(SettingsKey::META_ACCESS_TOKEN, true, true),
  25.             'messages'=>$messageSummary,
  26.             'user'=>SerializerService::serialize($this->getUser(), SerializerService::ENCODER_ARRAY)
  27.         ]);
  28.     }
  29. }