<?php declare(strict_types=1);
namespace App\Controller;
use App\Entity\NotificationEntity;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Response;
use Doctrine\ORM\EntityManagerInterface;
/**
* Default Controller.
*/
class DefaultController extends AbstractController
{
#[Route("/", name:"index")]
public function index(EntityManagerInterface $entityManager): Response
{
$repo = $entityManager->getRepository(NotificationEntity::class);
$notifications = $repo->findBy([], [ "eventTimestamp" => "ASC "]);
return $this->render('default/index.html.twig', [ 'notifications' => $notifications ]);
}
#[Route("/readme", name:"readme")]
public function readme(): Response
{
return new Response('Hallo Welt');
}
#[Route("/notifications", name:"notifications")]
public function notifications(EntityManagerInterface $entityManager): Response
{
$notifications = $entityManager
->getRepository(NotificationEntity::class)
->findBy([], [ "eventTimestamp" => "ASC "]);
return $this->json([
'success' => 'true',
'result' => $notifications
]);
}
}