From e3fedb0ea958c509c3ef36b729fe2b1a99a64c93 Mon Sep 17 00:00:00 2001 From: tracer Date: Fri, 4 Nov 2022 10:33:27 +0100 Subject: [PATCH] support for user details --- src/Controller/PagesController.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Controller/PagesController.php b/src/Controller/PagesController.php index 0f51151..bab1948 100644 --- a/src/Controller/PagesController.php +++ b/src/Controller/PagesController.php @@ -4,6 +4,7 @@ namespace App\Controller; use App\Entity\Pages; use App\Repository\PagesRepository; +use App\Repository\UserRepository; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; @@ -11,7 +12,7 @@ use Symfony\Component\Routing\Annotation\Route; class PagesController extends AbstractController { #[Route(path: '/pages/{slug}', name: 'pages_display')] - public function display(PagesRepository $pagesRepository, string $slug): Response + public function display(PagesRepository $pagesRepository, UserRepository $userRepository, string $slug): Response { $page = $pagesRepository->findOneBy([ 'slug' => $slug, @@ -23,10 +24,17 @@ class PagesController extends AbstractController $page->setContent(content: '404 - The requested page was not found.'); } + dump($page); + dump($page->getOwner()); + $user = $userRepository->findOneBy(['id' => $page->getOwner()->getId()]); + dd($user); + return $this->render(view: '@default/pages/index.html.twig', parameters: [ 'page_name' => $page->getName(), - 'page_content' => $page->getContent() - + 'page_content' => $page->getContent(), + 'created_at' => $page->getCreatedAt(), + 'modified_at' => $page->getModifiedAt(), + 'owner' => $page->getOwner() ]); } }