<?php

namespace App\Controller;

use App\Entity\Site\Page;
use Lc\SovBundle\Doctrine\EntityManager;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;


class IndexController extends AbstractController
{
        protected $em;
        protected $mailer;

        public function __construct(EntityManager $em)
        {
                $this->em = $em;
        }

        public function index(): Response
        {
                $pageRepository = $this->em->getRepository(Page::class);
                $pages = $pageRepository->findAll();

                return $this->render('page/index.html.twig', [
                        'controller_name' => 'IndexController',
                        'pages' => $pages
                ]);
        }

        public function page($pageSlug): Response
        {
                $pageRepository = $this->em->getRepository(Page::class);
                $page = $pageRepository->findOneBySlug($pageSlug);


                return $this->render('page/page.html.twig', [
                        'controller_name' => 'IndexController',
                        'page' => $page
                ]);
        }
}
