src/Controller/Subscription/ShowSubscriptionLandingPageAction.php line 15

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Slivki\Controller\Subscription;
  4. use Slivki\Controller\SiteController;
  5. use Slivki\Repository\BatchCodes\BatchCodesPlanRepositoryInterface;
  6. use Slivki\Services\Subscription\SubscriptionPlanService;
  7. use Slivki\Services\Subscription\SubscriptionService;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\HttpKernel\KernelInterface;
  10. use Symfony\Component\Routing\Annotation\Route;
  11. final class ShowSubscriptionLandingPageAction extends SiteController
  12. {
  13.     /**
  14.      * @Route("/subscription-landing/{offerId}/{codesCount}",
  15.      *   methods={"GET"},
  16.      *   name="show_subscription_landing_page"
  17.      * )
  18.      */
  19.     public function __invoke(
  20.         SubscriptionService $subscriptionService,
  21.         SubscriptionPlanService $subscriptionPlanService,
  22.         BatchCodesPlanRepositoryInterface $batchCodesPlanRepository,
  23.         int $codesCount 1,
  24.         int $offerId null
  25.     ): Response {
  26.         $user $this->getUser();
  27.         if ($user && $subscriptionService->isSubscriber($user)) {
  28.             return $this->redirectToRoute('profileSubscription');
  29.         }
  30.         $hadSubscription $user && $subscriptionService->isExistBySubscriber($user);
  31.         $demoSubscription = !$hadSubscription
  32.             $subscriptionPlanService->getTrialPlan()
  33.             : null;
  34.         return $this->render('Slivki/landing-subscription/index.html.twig', [
  35.             'offerID' => $offerId,
  36.             'codesCount' => $codesCount,
  37.             'subscriptionPlanList' => $subscriptionPlanService->getSubscriptionPlans(),
  38.             'subscriptionPlanForLegalEntitiesList' => $subscriptionPlanService->getForLegalEntityPlans(),
  39.             'hadSubscription' => $hadSubscription,
  40.             'demoSubscription' => $demoSubscription,
  41.             'batchCodesPlans' => $batchCodesPlanRepository->findAllActive(),
  42.         ]);
  43.     }
  44. }