2026-04-09 20:21:01 +02:00
|
|
|
<?php declare(strict_types=1);
|
2019-10-27 18:51:03 +01:00
|
|
|
/**
|
|
|
|
|
* This file is part of the SplendidBear Websites' projects.
|
|
|
|
|
*
|
|
|
|
|
* Copyright (c) 2019 @ www.splendidbear.org
|
|
|
|
|
*
|
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
|
*/
|
2019-10-27 13:35:33 +01:00
|
|
|
|
|
|
|
|
namespace App\Controller;
|
|
|
|
|
|
2026-04-15 18:35:05 +02:00
|
|
|
use App\Entity\ContactMessage;
|
|
|
|
|
use App\Form\ContactFormType;
|
|
|
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
|
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
|
use RuntimeException;
|
|
|
|
|
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
|
2019-10-27 18:51:03 +01:00
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
2026-04-09 15:01:38 +02:00
|
|
|
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
2026-04-15 18:35:05 +02:00
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
2019-10-27 18:51:03 +01:00
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
2026-04-12 08:01:46 +02:00
|
|
|
use Symfony\Component\HttpKernel\Attribute\AsController;
|
2026-04-15 18:35:05 +02:00
|
|
|
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
|
|
|
|
|
use Symfony\Component\Mailer\MailerInterface;
|
2026-04-10 12:33:38 +02:00
|
|
|
use Symfony\Component\Routing\Attribute\Route;
|
2019-10-27 13:35:33 +01:00
|
|
|
|
2019-10-27 18:51:03 +01:00
|
|
|
/**
|
|
|
|
|
* Class GameController
|
|
|
|
|
*
|
2026-04-09 20:21:01 +02:00
|
|
|
* @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. 09.
|
2019-10-27 18:51:03 +01:00
|
|
|
*/
|
2026-04-12 08:01:46 +02:00
|
|
|
#[AsController]
|
2019-10-27 18:51:03 +01:00
|
|
|
class GameController extends AbstractController
|
2019-10-27 13:35:33 +01:00
|
|
|
{
|
2026-04-09 15:01:38 +02:00
|
|
|
public function __construct(
|
|
|
|
|
#[Autowire(env: 'APP_ENV')]
|
2026-04-15 18:35:05 +02:00
|
|
|
private readonly string $env,
|
2026-04-09 22:00:53 +02:00
|
|
|
#[Autowire(env: 'MERCURE_PUBLIC_URL')]
|
2026-04-15 18:35:05 +02:00
|
|
|
private readonly string $mercurePublicUrl,
|
2026-04-09 22:00:53 +02:00
|
|
|
#[Autowire(env: 'MERCURE_SUBSCRIBER_JWT')]
|
2026-04-15 18:35:05 +02:00
|
|
|
private readonly string $mercureSubscriberJwt,
|
|
|
|
|
#[Autowire(env: 'APP_CONTACT_MAIL_ADDRESS')]
|
|
|
|
|
private readonly string $appContactMailAddress,
|
|
|
|
|
private readonly LoggerInterface $logger,
|
2026-04-09 15:01:38 +02:00
|
|
|
) {
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-10 12:33:38 +02:00
|
|
|
#[Route('/', name: 'MineSeekerBundle_homepage')]
|
2019-10-27 18:51:03 +01:00
|
|
|
public function index(): Response
|
2019-10-27 13:35:33 +01:00
|
|
|
{
|
|
|
|
|
return $this->render('Game/index.html.twig');
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-10 12:33:38 +02:00
|
|
|
#[Route('/play', name: 'MineSeekerBundle_gamePlay')]
|
|
|
|
|
#[Route('/play/{gameAssoc}', name: 'MineSeekerBundle_gamePlayWId')]
|
2026-04-09 20:21:01 +02:00
|
|
|
public function play(): Response
|
2019-10-27 13:35:33 +01:00
|
|
|
{
|
2026-04-09 20:21:01 +02:00
|
|
|
return $this->render('Game/play.html.twig', [
|
2026-04-09 22:00:53 +02:00
|
|
|
'env' => $this->env,
|
|
|
|
|
'mercure_hub_url' => $this->mercurePublicUrl,
|
|
|
|
|
'mercure_subscriber_jwt' => $this->mercureSubscriberJwt,
|
2026-04-09 20:21:01 +02:00
|
|
|
]);
|
2019-10-27 13:35:33 +01:00
|
|
|
}
|
|
|
|
|
|
2026-04-10 12:33:38 +02:00
|
|
|
#[Route('/privacy-policy', name: 'MineSeekerBundle_privacy')]
|
2019-10-27 18:51:03 +01:00
|
|
|
public function privacy(): Response
|
2019-10-27 13:35:33 +01:00
|
|
|
{
|
|
|
|
|
return $this->render('Official/privacy.html.twig');
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-10 12:33:38 +02:00
|
|
|
#[Route('/terms-of-service', name: 'MineSeekerBundle_terms')]
|
2019-10-27 18:51:03 +01:00
|
|
|
public function terms(): Response
|
2019-10-27 13:35:33 +01:00
|
|
|
{
|
|
|
|
|
return $this->render('Official/terms.html.twig');
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-10 12:33:38 +02:00
|
|
|
#[Route('/contact', name: 'MineSeekerBundle_contact')]
|
2026-04-15 18:35:05 +02:00
|
|
|
public function contact(
|
|
|
|
|
Request $request,
|
|
|
|
|
EntityManagerInterface $em,
|
|
|
|
|
MailerInterface $mailer,
|
|
|
|
|
): Response {
|
|
|
|
|
$contactMessage = new ContactMessage();
|
|
|
|
|
$form = $this->createForm(ContactFormType::class, $contactMessage);
|
|
|
|
|
$form->handleRequest($request);
|
|
|
|
|
|
|
|
|
|
if ($form->isSubmitted() && $form->isValid()) {
|
|
|
|
|
$contactMessage->setIpAddress($request->getClientIp());
|
|
|
|
|
$em->persist($contactMessage);
|
|
|
|
|
$em->flush();
|
|
|
|
|
$this->sendMail($mailer, $contactMessage);
|
|
|
|
|
$this->addFlash('contact_success', 'Thank you for your message! We will get back to you soon.');
|
|
|
|
|
|
|
|
|
|
return $this->redirectToRoute('MineSeekerBundle_contact');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this->render('Official/contact.html.twig', [
|
|
|
|
|
'form' => $form,
|
|
|
|
|
]);
|
2019-10-27 13:35:33 +01:00
|
|
|
}
|
|
|
|
|
|
2026-04-10 12:33:38 +02:00
|
|
|
#[Route('/landing-page', name: 'MineSeekerBundle_landing')]
|
2019-10-27 18:51:03 +01:00
|
|
|
public function landing(): Response
|
2019-10-27 13:35:33 +01:00
|
|
|
{
|
|
|
|
|
return $this->render('Official/landing.html.twig');
|
|
|
|
|
}
|
2026-04-15 18:35:05 +02:00
|
|
|
|
|
|
|
|
public function sendMail(MailerInterface $mailer, ContactMessage $contactMessage): void
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$mailer->send(
|
|
|
|
|
new TemplatedEmail()
|
|
|
|
|
->from('noreply@mineseeker.hu')
|
|
|
|
|
->to($this->appContactMailAddress)
|
|
|
|
|
->replyTo($contactMessage->getEmail())
|
|
|
|
|
->subject('New Contact Message from ' . $contactMessage->getName())
|
|
|
|
|
->htmlTemplate('emails/contact_notification.html.twig')
|
|
|
|
|
->context(['message' => $contactMessage])
|
|
|
|
|
);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
$this->logger->error('Failed to send contact notification email: ' . $e->getMessage(), [
|
|
|
|
|
'exception' => $e,
|
|
|
|
|
'message' => $contactMessage,
|
|
|
|
|
]);
|
|
|
|
|
throw new RuntimeException('Failed to send contact notification email: ' . $e->getMessage());
|
|
|
|
|
} catch (TransportExceptionInterface $e) {
|
|
|
|
|
$this->logger->error('Failed to send contact notification email: ' . $e->getMessage(), [
|
|
|
|
|
'exception' => $e,
|
|
|
|
|
'message' => $contactMessage,
|
|
|
|
|
]);
|
|
|
|
|
throw new RuntimeException('Failed to send contact notification email: ' . $e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-10-27 13:35:33 +01:00
|
|
|
}
|