<?php
namespace App\Controller\Frontend;
use App\Controller\Base\BaseController;
use App\Entity\TInfografik;
use Symfony\Component\Routing\Annotation\Route;
use Kematjaya\Breadcrumb\Lib\Builder as BreacrumbBuilder;
use App\Repository\MSektorRepository;
use App\Repository\TDivRepository;
use App\Repository\TPublikasiRepository;
use Symfony\Component\HttpFoundation\Request;
use Sonata\SeoBundle\Seo\SeoPageInterface;
class HomepageController extends BaseController
{
/**
* @Route("/", name="homepage")
*/
public function index(SeoPageInterface $seoPage, MSektorRepository $MSektorRepo, TDivRepository $TDivRepo, TPublikasiRepository $TPubRepo)
{
$seoPage->addTitlePrefix(
"Homepage"
);
$infografik = $this->getDoctrine()->getRepository(TInfografik::class);
$infografik = $infografik->findAll();
$total_infografik = count($infografik);
$total_div = $TDivRepo->getTDiv();
$total_div = count($total_div);
$total_pub = $TPubRepo->getPub();
$total_pub = count($total_pub);
$sektoral = $MSektorRepo->findAll();
$total_sektoral = count($sektoral);
$highlight = $this->highlight();
// dump($this->dashboardSearch(''));exit;
// dump($highlight);exit;
return $this->render('frontend/index.html.twig', [
'header_kategori' => $this->getHeaderKategori(),
'total_div' => $total_div,
'total_infografik' => $total_infografik,
'total_pub' => $total_pub,
'total_sektoral' => $total_sektoral,
'highlight' => $highlight
]);
}
/**
* @Route("/gsearch.html",name="gsearch", methods={"POST", "GET"})
*/
public function gsearch(Request $request){
$key = $request->get('key');
$data = $this->dashboardSearch($key);
$dataset = array();
foreach($data as $dt)
{
$dataset[] = array(
'id' => $dt['id'],
'judul' => str_ireplace($key, "<strong>" .$key. "</strong>" ,$dt['judul']),
'judulx' => $dt['judul'],
'tipe' => $dt['tipe']
);
// break;
}
return $this->json($dataset);
}
/**
* @Route("/pencarian.html",name="search", methods={"POST", "GET"})
*/
public function search(Request $request)
{
$key = $request->get('key');
$data = $this->dashboardSearch($key);
// dump($data);exit;
return $this->render('frontend/search.html.twig', [
'data' => $data,
'header_kategori' => $this->getHeaderKategori(),
]);
}
/**
* @Route("/visualisasi", name="visualisasi", methods={"POST", "GET"})
*/
public function visualisasi(Request $request)
{
return $this->render('/frontend/visualisasi/index.html.twig', [
]);
}
}