support for user details

This commit is contained in:
tracer 2022-11-04 10:33:27 +01:00
parent fec6ae5db5
commit e3fedb0ea9

View File

@ -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()
]);
}
}