Private
Public Access
1
0
Files
MineSeeker/src/Controller/ProfileController.php

53 lines
1.7 KiB
PHP

<?php declare(strict_types=1);
/*
* This file is part of the SplendidBear Websites' projects.
*
* Copyright (c) 2026 @ www.splendidbear.org
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Controller;
use App\Entity\User;
use App\Repository\PlayedGameRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\AsController;
use Symfony\Component\Routing\Attribute\Route;
/**
* Class ProfileController
*
* @package App\Controller
* @author Lang <https://www.splendidbear.org>
* @category Class
* @license https://www.gnu.org/licenses/lgpl-3.0.en.html GNU Lesser General Public License
* @link www.splendidbear.org
* @since 2026. 04. 11.
*/
#[AsController]
class ProfileController extends AbstractController
{
public function __construct(private readonly PlayedGameRepository $repo) { }
#[Route('/profile', name: 'MineSeekerBundle_profile')]
public function index(): Response
{
/** @var User $user */
$user = $this->getUser();
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED');
return $this->render('Security/profile.html.twig', [
'stats' => [
'total' => $this->repo->countFinishedForUser($user),
'wins' => $this->repo->countWinsForUser($user),
'losses' => $this->repo->countLossesForUser($user),
'bombs' => $this->repo->countBombsForUser($user),
],
'recent' => $this->repo->findRecentFinishedForUser($user),
]);
}
}