<?php
namespace App\Controller\Frontend;
use App\Controller\Base\BaseController;
use App\Entity\TInfografik;
use App\Filter\TInfografikFilterType;
use App\Repository\MKategoriDetailRepository;
use App\Repository\MUrusanDetailRepository;
use App\Repository\TDokumenRepository;
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 ListPublikasiController extends BaseController
{
/**
* @Route("/list-publikasi", name="list-publikasi")
*/
public function index(SeoPageInterface $seoPage, TDokumenRepository $tDokumenRepo, MKategoriDetailRepository $mKategoriDetailRepo, MUrusanDetailRepository $mUrusanDetailRepository,
PaginatorInterface $paginatorInterface, Request $request): Response
{
$seoPage->addTitlePrefix("Daftar Rilis Publikasi");
// Set tahun yang diinginkan
$year = 2023;
$startDate = new \DateTime("$year-01-01");
$endDate = new \DateTime(($year + 1) . "-01-01");
$queryBuilder = $this->getQueryBuilder(TInfografik::class)
->andWhere("this.is_arsip = false")
->andWhere("lower(this.judul) LIKE lower(:judul)")
->andWhere("this.release_date >= :startDate")
->andWhere("this.release_date < :endDate")
->setParameter('judul', '%' . $request->get('judul', '') . '%')
->setParameter('startDate', $startDate)
->setParameter('endDate', $endDate)
->addOrderBy('this.release_date', 'desc');
$pagination = $paginatorInterface->paginate($queryBuilder, $request->query->getInt('page', 1), 10);
$filter = TInfografikFilterType::class;
$classInfo = TInfografik::class;
$form = $this->get('form.factory')->create($filter, $this->getFilters($filter));
$queryBuilder = $this->getQueryBuilder($classInfo);
$queryBuilder = $this->buildFilter($request, $form, $queryBuilder)->addOrderBy("this.id", "DESC");
dump($pagination);
return $this->render('frontend/list_publikasi/index.html.twig', [
'pagination' => $pagination,
'search' => array('judul'=>$request->get('judul', '')),
'page_name' => 'list_publikasi',
'filter' => $form->createView(),
]);
}
}