<?php
declare(strict_types=1);
namespace Slivki\Controller\Subscription;
use Slivki\Controller\SiteController;
use Slivki\Repository\BatchCodes\BatchCodesPlanRepositoryInterface;
use Slivki\Services\Subscription\SubscriptionPlanService;
use Slivki\Services\Subscription\SubscriptionService;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Routing\Annotation\Route;
final class ShowSubscriptionLandingPageAction extends SiteController
{
/**
* @Route("/subscription-landing/{offerId}/{codesCount}",
* methods={"GET"},
* name="show_subscription_landing_page"
* )
*/
public function __invoke(
SubscriptionService $subscriptionService,
SubscriptionPlanService $subscriptionPlanService,
BatchCodesPlanRepositoryInterface $batchCodesPlanRepository,
int $codesCount = 1,
int $offerId = null
): Response {
$user = $this->getUser();
if ($user && $subscriptionService->isSubscriber($user)) {
return $this->redirectToRoute('profileSubscription');
}
$hadSubscription = $user && $subscriptionService->isExistBySubscriber($user);
$demoSubscription = !$hadSubscription
? $subscriptionPlanService->getTrialPlan()
: null;
return $this->render('Slivki/landing-subscription/index.html.twig', [
'offerID' => $offerId,
'codesCount' => $codesCount,
'subscriptionPlanList' => $subscriptionPlanService->getSubscriptionPlans(),
'subscriptionPlanForLegalEntitiesList' => $subscriptionPlanService->getForLegalEntityPlans(),
'hadSubscription' => $hadSubscription,
'demoSubscription' => $demoSubscription,
'batchCodesPlans' => $batchCodesPlanRepository->findAllActive(),
]);
}
}