src/Controller/DefaultController.php line 18

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace App\Controller;
  3. use App\Entity\NotificationEntity;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Doctrine\ORM\EntityManagerInterface;
  8. /**
  9.  * Default Controller.
  10.  */
  11. class DefaultController extends AbstractController
  12. {
  13.     #[Route("/"name:"index")]
  14.     public function index(EntityManagerInterface $entityManager): Response
  15.     {
  16.         $repo $entityManager->getRepository(NotificationEntity::class);
  17.         $notifications $repo->findBy([], [ "eventTimestamp" => "ASC "]);
  18.         
  19.         return $this->render('default/index.html.twig', [ 'notifications' => $notifications ]);
  20.     }
  21.     #[Route("/readme"name:"readme")]
  22.     public function readme(): Response
  23.     {
  24.         return new Response('Hallo Welt');
  25.     }
  26.     #[Route("/notifications"name:"notifications")]
  27.     public function notifications(EntityManagerInterface $entityManager): Response
  28.     {
  29.         $notifications $entityManager
  30.                 ->getRepository(NotificationEntity::class)
  31.                 ->findBy([], [ "eventTimestamp" => "ASC "]);
  32.         
  33.         return $this->json([
  34.             'success' => 'true',
  35.             'result' => $notifications
  36.         ]);
  37.     }
  38. }