<?php
namespace App\Package\Openform\Front\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\RequestStack;
use App\Package\Openform\Front\Controller\BaseController;
use App\Package\Toolkit\RouteLocalizer\RouteLocalizer;
use Doctrine\ORM\EntityManagerInterface;
use App\Package\Openform\Entity\News;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* IndexController
*
* @author Daniel Balowski <d.balowski@openform.pl> (_creator)
* @copyright 2019 Openform
* @since 05.2019
*/
class IndexController extends BaseController
{
private $em;
public function __construct(RequestStack $request, RouteLocalizer $routeLocalizer, EntityManagerInterface $em)
{
parent::__construct($request, $routeLocalizer, $em);
$this->em = $em;
}
public function indexAction(Request $request): Response
{
$entity = $this->getPageByIdname('page_home', $request->getLocale());
if (!$entity) {
throw new NotFoundHttpException();
}
$newsFrontRepo = $this->em->getRepository(News::class)->getFrontRepository();
return $this->render('@openform_front_templates/Index/index.html.twig', [
'entity' => $entity,
'featuredNews' => $newsFrontRepo->getHomePageFeaturedNews($request->getLocale()),
//'remainingNews' => $newsFrontRepo->getRemainingNews($request->getLocale()),
]);
}
}