<?php
namespace App\Controller\Frontend;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse;
use Nzo\UrlEncryptorBundle\Annotations\ParamDecryptor;
use Nzo\UrlEncryptorBundle\Annotations\ParamEncryptor;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Security\Core\Security;
use App\Service\HelperService;
use Symfony\Component\String\Slugger\SluggerInterface;
use Nzo\UrlEncryptorBundle\Encryptor\Encryptor;
use Symfony\Component\HttpFoundation\RequestStack;
class FooterController extends AbstractController
{
private $requestStack;
public function __construct(RequestStack $requestStack)
{
$this->requestStack = $requestStack;
}
public function footerAction(Request $request)
{
$masterRequest = $this->requestStack->getMainRequest();
$path = $masterRequest->getPathInfo();
$slugArray = explode("/", $path);
$slug = "";
if(count($slugArray) > 0)
{
$slug = $slugArray[1];
}
$em = $this->getDoctrine()->getManager();
$client = $em->getRepository(\App\Entity\Client::class)->findOneBy(array('slug' => $slug));
$webSetting = $em->getRepository(\App\Entity\WebSetting::class)->findOneBy(array("Client" => $client));
$brands = $em->getRepository(\App\Entity\Brand::class)->findBy(array('is_active' => 1, 'Client' => $client));
$policies = $em->getRepository(\App\Entity\Policy::class)->findBy(array('is_active' => 1, 'Client' => $client));
return $this->render('Frontend/footer.html.twig',
array(
'brands' => $brands,
'policies' => $policies,
'brand' => '',
'category' => '',
'information' => $client,
'webSetting' => $webSetting,
'slug' => $slug
));
}
/**
* @Route("/{slug}/policies", name="footer_policy")
*/
public function policyAction (Request $request, $slug)
{
$policyId = $request->get('id');
$em = $this->getDoctrine()->getManager();
$client = $em->getRepository(\App\Entity\Client::class)->findOneBy(array("slug" => $slug));
$policy = $em->getRepository(\App\Entity\Policy::class)->findOneBy(array('policyId' => $policyId));
if($policy)
{
$name = $policy->getName();
$lastDate = $policy->getCreatedAt()->format('M-Y');
$content = $policy->getContentText();
}
return $this->render('Frontend/Footer/index.html.twig',array(
'name' => $name,
'lastDate' => $lastDate,
'content' => $content,
'productCategory' => '',
'pager_limit' => 12,
'globalSearch' => '',
'brand' => '',
'category' => '',
'slug' => $slug
));
}
}