Compare commits

...

3 Commits

Author SHA1 Message Date
tracer 5115df745a support for page details 2022-11-04 10:33:44 +01:00
tracer e3fedb0ea9 support for user details 2022-11-04 10:33:27 +01:00
tracer fec6ae5db5 minor code improvements 2022-11-04 10:32:59 +01:00
3 changed files with 15 additions and 5 deletions

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

View File

@ -23,7 +23,7 @@ class PagesRepository extends ServiceEntityRepository
public function add(Pages $entity, bool $flush = true): void
{
$this->_em->persist($entity);
$this->_em->persist(entity: $entity);
if ($flush) {
$this->_em->flush();
}
@ -31,7 +31,7 @@ class PagesRepository extends ServiceEntityRepository
public function remove(Pages $entity, bool $flush = true): void
{
$this->_em->remove($entity);
$this->_em->remove(entity: $entity);
if ($flush) {
$this->_em->flush();
}

View File

@ -4,4 +4,6 @@
{% block body %}
{{ page_content | raw }}
<br>
Page created by: {{ owner }} at {{ created_at }}
{% endblock %}