<?php
namespace Kobizo\Bundle\CoreBundle\Controller;
use Kobizo\Bundle\CmsBundle\Controller\Page\GetPageTranslationHelper;
use Kobizo\Component\Attributes\SlugAttribute;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class FeDefaultController extends KobizoFeAbstractController
{
/**
* @Route("/", name="home", methods={"GET"})
*/
public function index(
Request $request,
GetPageTranslationHelper $getPageTranslationHelper
): Response {
$locale = $request->getLocale();
$pageTranslation = $getPageTranslationHelper->getByLocaleAndSlug($locale, SlugAttribute::DEFAULT_HOMEPAGE_SLUG);
$page = $pageTranslation ? $pageTranslation->getPage() : null;
return $this->render('@KobizoCore/frontend/index.twig', [
'locale' => $request->getLocale(),
'page' => $page,
'translation' => $pageTranslation,
'title' => $pageTranslation ? $pageTranslation->getTitle() : null,
'content' => $pageTranslation ? $pageTranslation->getContent() : null,
'tags' => $page ? $page->getTags() : [],
'author' => $page ? $page->getAuthor() : null,
'authorName' => $page ? $page->getAuthor()->getDisplayName() : null,
'comments' => $page ? $page->getComments() : [],
]);
}
}