Source Controller
This commit is contained in:
68
src/Controller/DefaultController.php
Normal file
68
src/Controller/DefaultController.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Note;
|
||||
use App\Entity\Reference;
|
||||
use App\Entity\User;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Security\Http\Attribute\CurrentUser;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
|
||||
class DefaultController extends AbstractController
|
||||
{
|
||||
#[Route('/', name: 'app_index')]
|
||||
public function index(): Response
|
||||
{
|
||||
return $this->render('default/index.html.twig');
|
||||
}
|
||||
|
||||
#[Route('/home', name: 'app_home')]
|
||||
public function home(Request $req, EntityManagerInterface $emi, #[CurrentUser()] ?User $user): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
|
||||
$last4Notes = $emi->getRepository(Note::class)->getLast4Notes($user);
|
||||
$uuid = Uuid::v4();
|
||||
|
||||
return $this->render('default/home.html.twig', [
|
||||
'last4Notes' => $last4Notes,
|
||||
'id' => $uuid,
|
||||
'isAdmin' => $this->isGranted('ROLE_ADMIN'),
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/reference-editor', name: 'app_reference_editor')]
|
||||
public function referenceEditor(EntityManagerInterface $emi): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted('ROLE_ADMIN');
|
||||
|
||||
$creeds = $emi->getRepository(Reference::class)->findByType('creed');
|
||||
$belgic = $emi->getRepository(Reference::class)->findByType('belgic');
|
||||
$heidelberg = $emi->getRepository(Reference::class)->findByType('heidelberg');
|
||||
$dort = $emi->getRepository(Reference::class)->findByType('dort');
|
||||
$wcf = $emi->getRepository(Reference::class)->findByType('wcf');
|
||||
$wsc = $emi->getRepository(Reference::class)->findByType('wsc');
|
||||
$wlc = $emi->getRepository(Reference::class)->findByType('wlc');
|
||||
|
||||
return $this->render('editors/reference-editor.html.twig', [
|
||||
'creeds' => $creeds,
|
||||
'belgic' => $belgic,
|
||||
'heidelberg' => $heidelberg,
|
||||
'dort' => $dort,
|
||||
'wcf' => $wcf,
|
||||
'wsc' => $wsc,
|
||||
'wlc' => $wlc
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/template-editor', name: 'app_template_editor')]
|
||||
public function templateEditor(): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
|
||||
return $this->render('editors/template-editor.html.twig');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user