<?php
declare(strict_types=1);
namespace Slivki\Controller\Gift;
use Slivki\Enum\SwitcherFeatures;
use Slivki\Paginator\Gift\GiftCertificatePaginatorInterface;
use Slivki\Services\Switcher\ServerFeatureStateChecker;
use Slivki\Util\CommonUtil;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
final class GetGiftCertificateAction extends AbstractController
{
private ServerFeatureStateChecker $serverFeatureStateChecker;
public function __construct(ServerFeatureStateChecker $serverFeatureStateChecker)
{
$this->serverFeatureStateChecker = $serverFeatureStateChecker;
}
/**
* @Route("/gift", name="gift_index", methods={"GET"})
*/
public function __invoke(Request $request): Response
{
if (!$this->serverFeatureStateChecker->isServerFeatureEnabled(SwitcherFeatures::GIFTS())) {
return new Response('', Response::HTTP_NOT_FOUND);
}
$view = CommonUtil::isMobileDevice($request)
? 'Slivki/mobile/orderAsGift/index_certificate_all.html.twig'
: 'Slivki/orderAsGift/index_certificate_all.html.twig';
return $this->render($view, [
'sorts' => GiftCertificatePaginatorInterface::SORT,
'defaultSort' => GiftCertificatePaginatorInterface::DEFAULT_SORT,
]);
}
}