2026-04-11 20:45:51 +02:00
|
|
|
<?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;
|
2026-04-12 08:01:46 +02:00
|
|
|
use App\Repository\PlayedGameRepository;
|
2026-04-11 20:45:51 +02:00
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
2026-04-12 08:01:46 +02:00
|
|
|
use Symfony\Component\HttpKernel\Attribute\AsController;
|
2026-04-11 20:45:51 +02:00
|
|
|
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.
|
|
|
|
|
*/
|
2026-04-12 08:01:46 +02:00
|
|
|
#[AsController]
|
2026-04-11 20:45:51 +02:00
|
|
|
class ProfileController extends AbstractController
|
|
|
|
|
{
|
2026-04-12 08:01:46 +02:00
|
|
|
public function __construct(private readonly PlayedGameRepository $repo) { }
|
|
|
|
|
|
2026-04-11 20:45:51 +02:00
|
|
|
#[Route('/profile', name: 'MineSeekerBundle_profile')]
|
2026-04-12 08:01:46 +02:00
|
|
|
public function index(): Response
|
2026-04-11 20:45:51 +02:00
|
|
|
{
|
|
|
|
|
/** @var User $user */
|
|
|
|
|
$user = $this->getUser();
|
2026-04-12 08:01:46 +02:00
|
|
|
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED');
|
2026-04-11 20:45:51 +02:00
|
|
|
|
|
|
|
|
return $this->render('Security/profile.html.twig', [
|
2026-04-12 08:01:46 +02:00
|
|
|
'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),
|
2026-04-11 20:45:51 +02:00
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|