notes index
This commit is contained in:
@@ -11,11 +11,12 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use function Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class GuiController extends AbstractController {
|
||||
#[Route('/')]
|
||||
#[Template('/index.html.twig')]
|
||||
public function index(): Array {
|
||||
public function index(): array {
|
||||
return [
|
||||
'title' => 'Joe Carstairs',
|
||||
'description' => 'Joe Carstairs\' personal website',
|
||||
@@ -24,27 +25,15 @@ class GuiController extends AbstractController {
|
||||
|
||||
#[Route('/notes', name: 'notes')]
|
||||
#[Template('/notes.html.twig')]
|
||||
public function notes(): Array {
|
||||
return [
|
||||
'title' => 'Joe Carstairs\' notes',
|
||||
'description' => 'Joe Carstairs\' notes',
|
||||
];
|
||||
}
|
||||
|
||||
#[Route('/note/{slug}', name: 'note')]
|
||||
#[Template('/note.html.twig')]
|
||||
public function note(
|
||||
public function notes(
|
||||
EntityManagerInterface $entityManager,
|
||||
string $slug,
|
||||
): array {
|
||||
$repository = $entityManager->getRepository(Note::class);
|
||||
$note = $repository->findOneBy(['slug' => $slug]);
|
||||
$notes = $entityManager->getRepository(Note::class)->findAll();
|
||||
|
||||
return [
|
||||
'title' => 'Joe Carstairs\' notes',
|
||||
'description' => 'Joe Carstairs\' notes',
|
||||
'note' => $note,
|
||||
'slug' => $slug,
|
||||
'notes' => $notes,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -84,4 +73,24 @@ class GuiController extends AbstractController {
|
||||
'form' => $form,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string,mixed>
|
||||
*/
|
||||
#[Route('/notes/{slug}', name: 'note')]
|
||||
#[Template('/note.html.twig')]
|
||||
public function note(
|
||||
EntityManagerInterface $entityManager,
|
||||
string $slug,
|
||||
): array {
|
||||
$repository = $entityManager->getRepository(Note::class);
|
||||
$note = $repository->findOneBy(['slug' => $slug]);
|
||||
|
||||
return [
|
||||
'title' => 'Joe Carstairs\' notes',
|
||||
'description' => 'Joe Carstairs\' notes',
|
||||
'note' => $note,
|
||||
'slug' => $slug,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user