<?php
namespace FoundersBundle\Controller;
use Doctrine\ORM\EntityManagerInterface;
use FoundersBundle\Model\Post;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class MainController extends BaseController
{
public function __construct(EntityManagerInterface $em)
{
parent::__construct($em);
}
public function index(Request $request, Post $postModel): Response
{
$posts = $postModel->getPostsWithLimit(6);
if (!$posts) {
throw new NotFoundHttpException();
}
return $this->baseFounderController('@Founders/Main/index.html.twig', [
'posts' => $posts,
]);
}
}