<?php
namespace App\Controller;
use App\Entity\Room;
use App\Form\RoomType;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\FormError;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class IndexController extends AbstractController
{
public function __construct(
private EntityManagerInterface $_em
) {}
/**
* @param Request $request
* @return Response
*/
#[Route("/", name: "index")]
public function index(Request $request): Response
{
$room = new Room();
$roomForm = $this->createForm(RoomType::class, $room);
$roomForm->handleRequest($request);
if ($roomForm->isSubmitted() && $roomForm->isValid()) {
/** @var Room $data */
$data = $roomForm->getData();
$result = $this->_em->getRepository(Room::class)->findOneBy(["roomId" => $data->getRoomId()]);
if ($result) {
return $this->redirectToRoute("public_room", ["roomId" => $result->getRoomId()]);
} else {
$roomForm->addError(new FormError('The room doesn’t exist'));
}
}
return $this->render('index.html.twig', [
'page_title' => 'Phasmophobia Randomizer',
'page_description' => 'Welcome back, we\'ve got some work ready for you!',
'meta_title' => 'Randomize your Phasmophobia game',
'meta_description' => 'Randomize your Phasmophobia games among various game modes such as classic, photo safari, night fever from 1 to 4 players. It’s a great way to make your Phasmophobia games more challenging!',
'roomEnter' => $roomForm->createView()
]);
}
/**
* @return Response
*/
#[Route(path: [
"en" => "/obs-guide",
"fr" => "/guide-pour-obs"
], name: "obs_guide")]
public function obs_guide(): Response
{
return $this->render('game/obs_guide.html.twig', [
'page_title' => 'Phasmophobia Randomizer',
'page_description' => 'Implement the randomizer on your lives',
'meta_title' => 'Phasmophobia Randomizer on OBS for Twitch',
'meta_description' => 'This guide allows you to integrate the content of your multiplayer games on your Twitch live through OBS.'
]);
}
}