<?php
namespace App\Controller\Frontend;
use App\Controller\Base\BaseController;
use App\Entity\TVisualisasi;
use App\Repository\TVisualisasiRepository;
use Knp\Component\Pager\PaginatorInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Sonata\SeoBundle\Seo\SeoPageInterface;
class VisualisasiController extends BaseController
{
/**
* @Route("/visualisasi", name="visualisasi", methods={"POST", "GET"})
*/
public function index(SeoPageInterface $seoPage, TVisualisasiRepository $tVisualisasiRepository,
PaginatorInterface $paginatorInterface, Request $request): Response
{
$seoPage->addTitlePrefix("Visualisasi");
$queryBuilder = $this->getQueryBuilder(TVisualisasi::class);
$pagination = $paginatorInterface->paginate($queryBuilder, $request->query->getInt('page', 1), 10);
$data_visualisasi = $tVisualisasiRepository->findAll();
return $this->render('frontend/visualisasi/index.html.twig', [
'controller_name' => 'VisualisasiController',
'data' => $data_visualisasi,
'pagination' => $pagination,
]);
}
/**
* @Route("/visualisasi/detail/{id}.html", name="detail_visualisasi", methods={"GET"})
*/
public function detail(?string $id, TVisualisasiRepository $tVisualisasiRepo): Response
{
$visualisasi = $tVisualisasiRepo->find($id);
// dump($visualisasi); exit;
$entityManager = $this->getDoctrine()->getManager();
$entityManager->persist($visualisasi);
$entityManager->flush();
return $this->render('frontend/visualisasi/detail.html.twig', [
'header_kategori' => $this->getHeaderKategori(),
'visualisasi' => $visualisasi,
]);
}
}