Private
Public Access
1
0

chg: usr: improve the gfx on homepage - implement login/register and activation for authentication - and add the first version of profile page #4

This commit is contained in:
2026-04-11 20:45:51 +02:00
parent eff849549b
commit 6b3e19b063
43 changed files with 3375 additions and 1806 deletions

View File

@@ -0,0 +1,83 @@
<?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 Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
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.
*/
class ProfileController extends AbstractController
{
#[Route('/profile', name: 'MineSeekerBundle_profile')]
public function index(EntityManagerInterface $em): Response
{
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED');
/** @var User $user */
$user = $this->getUser();
$finished = '(g.redPoints IS NOT NULL OR g.resign IS NOT NULL)';
$total = (int) $em->createQuery(
"SELECT COUNT(g.id) FROM App\Entity\PlayedGame g
WHERE (g.red = :u OR g.blue = :u) AND {$finished}"
)->setParameter('u', $user)->getSingleScalarResult();
$wins = (int) $em->createQuery(
"SELECT COUNT(g.id) FROM App\Entity\PlayedGame g WHERE (
(g.red = :u AND g.redPoints > g.bluePoints AND g.resign IS NULL) OR
(g.blue = :u AND g.bluePoints > g.redPoints AND g.resign IS NULL) OR
(g.red = :u AND g.resign = 'blue') OR
(g.blue = :u AND g.resign = 'red')
)"
)->setParameter('u', $user)->getSingleScalarResult();
$losses = (int) $em->createQuery(
"SELECT COUNT(g.id) FROM App\Entity\PlayedGame g WHERE (
(g.red = :u AND g.bluePoints > g.redPoints AND g.resign IS NULL) OR
(g.blue = :u AND g.redPoints > g.bluePoints AND g.resign IS NULL) OR
(g.red = :u AND g.resign = 'red') OR
(g.blue = :u AND g.resign = 'blue')
)"
)->setParameter('u', $user)->getSingleScalarResult();
$bombs = (int) $em->createQuery(
"SELECT COUNT(g.id) FROM App\Entity\PlayedGame g WHERE
(g.red = :u AND g.redExplodedBomb = true) OR
(g.blue = :u AND g.blueExplodedBomb = true)"
)->setParameter('u', $user)->getSingleScalarResult();
$recent = $em->createQuery(
"SELECT g FROM App\Entity\PlayedGame g
LEFT JOIN g.red rr LEFT JOIN g.blue bb
LEFT JOIN g.redAnon ra LEFT JOIN g.blueAnon ba
WHERE (g.red = :u OR g.blue = :u) AND {$finished}
ORDER BY g.updated DESC"
)->setParameter('u', $user)->setMaxResults(10)->getResult();
return $this->render('Security/profile.html.twig', [
'stats' => compact('total', 'wins', 'losses', 'bombs'),
'recent' => $recent,
]);
}
}