You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Web/Sources/src/app/controller/SocialController.php

71 lines
2.1 KiB

<?php
namespace App\Controller;
use App\Container;
use App\Router\Request\IRequest;
use App\Router\Response\Response;
use Database\AthleteGateway;
use Database\AthleteMapper;
use Database\Connexion;
use Database\NotificationGateway;
use Database\NotificationMapper;
use Shared\Attributes\Route;
use Twig\Environment;
use Data\Core\Preferences;
use Shared\Log;
class SocialController extends BaseController
{
private Environment $twig;
protected Preferences $preference;
public function __construct()
{
session_start();
$this->preference = new Preferences();
}
#[Route(path: '/notification', name: 'notification', methods: ['GET'])]
public function mail(): Response
{
try {
$notificationGateway = new NotificationGateway(new Connexion(DSN, DB_USER, DB_PASSWORD));
$listSearch = $notificationGateway->getNotifications();
$map = new NotificationMapper();
$notificationEntity = $map->notificationSqlToEntity($listSearch);
$listUsers = [];
foreach ($notificationEntity as $entity) {
$notification = $map->notificationEntityToModel($entity);
$listUsers[] = ['idnotif' => $notification->getId(), 'message' => $notification->getMessage(),
'date' => $notification->getDate(),'statut' => $notification->getStatut(), 'urgence' => $notification->getUrgence(),
'idathlete' => $notification->getToUserId()];
}
$response = $this->render('./page/notification.html.twig',[
'css' => $this->preference->getCookie(),
'pp' => "test2",
'user' => "Doe",
'role' => "Athlète",
'friendship' => [],
'analyzes' => [],
'mails' => $listUsers,
'users' => [],
'infoUser' => [],
'exos' => [],
'member' => []
]);
} catch (\Throwable $th) {
throw $th;
return $this->render("addfriend.html.twig", ['tabError' => $taberror]);
}
return $response;
}
}