<?php
namespace App\Controller\Forum;
use App\Entity\ForumCategory;
use App\Entity\ForumPost;
use App\Entity\ForumTopic;
use App\Repository\ForumCategoryRepository;
use App\Repository\ForumPostRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/forum")
*
*/
class ForumPageController extends AbstractController
{
/**
* @Route("/{country}", name="forum_public_country")
*
*/
public function byCountry(
ForumPostRepository $forumPostRepository,
ForumCategoryRepository $categoryRepository,
string $country
): Response
{
$categories = $categoryRepository->findBy(['countryMin' => $country]);
if (count($categories) == 0) {
throw $this->createNotFoundException();
}
return $this->render('forum/forum_page/byCountry.html.twig', [
'categories' => $categories,
'country' => $country,
'_recentPosts' => $forumPostRepository->recentPostLimit(5),
'_recentPostReplys' => $forumPostRepository->recentPostReply(5),
]);
}
}