<?php
/**
* Page Controller
*
* (c) Bertin van den Ham <b.vandenham@dappr.nl>
*/
namespace App\Controller;
use App\Manager\PageManager;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use VisualMedia\LisaBundle\Component\ManagerData;
use VisualMedia\NewsBundle\Manager\BaseNewsManager;
use VisualMedia\PageBundle\Controller\PageController as BasePageController;
/**
* Page Controller
*/
class PageController extends BasePageController
{
/**
* Ssi Page Expertise Action
*
* @param Request $request
* @param integer $count
* @param bool $shuffle
*
* @return Response
*/
public function ssiExpertiseAction(Request $request, ?int $count = null, bool $shuffle = false): Response
{
$manager = $this->get(PageManager::class);
$expertisePages = $manager->getIndex(new ManagerData(array(
$manager::OPTION_PUBLISHED => true,
$manager::OPTION_EXPERTISE => true
), array($manager::OPTION_ID => $manager::ORDER_DIR_ASC), $count));
if($shuffle) {
shuffle($expertisePages);
}
return $this->render('@VisualMediaPage/Ssi/ssi_expertises.html.twig', array(
'expertise_pages' => $expertisePages,
));
}
/**
* WebShopPopupClosed
*
* @param Request $request
*
* @return Response
*/
public function webShopPopupClosed(Request $request): Response
{
$expireDate = new \DateTime('+1 year', new \DateTimeZone('Europe/Amsterdam'));
$cookie = Cookie::create('webshop_popup_closed', true, $expireDate);
$response = new JsonResponse('success');
$response->headers->setCookie($cookie);
return $response;
}
}