src/Controller/HomeController.php line 27

  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Doctrine\Persistence\ManagerRegistry as PersistenceManagerRegistry;
  7. use App\Entity\Settings;
  8. use App\Entity\User;
  9. use App\Form\UserAgreementType;
  10. use Symfony\Component\HttpFoundation\RequestStack;
  11. use App\Service\LicenseService;
  12. use App\Service\SessionControlService;
  13. class HomeController extends AbstractController {
  14.     public function __construct(
  15.         private RequestStack $requestStack,
  16.         private SessionControlService $sessionControlService,
  17.         private LicenseService $licenseService,
  18.     ) {
  19.     }
  20.     #[Route(path'/'name'home')]
  21.     public function index(PersistenceManagerRegistry $doctrine): Response {
  22.         $user $this->getUser();
  23.         if ($user) {
  24.             if ($user->getPolicyAgreed() == 0) {
  25.                 $form $this->createForm(UserAgreementType::class, ['userid' => $user->getId()]);
  26.                 return $this->render(
  27.                     'panel/policyagreed.html.twig',
  28.                     ['form' => $form]
  29.                 );
  30.             }
  31.             if ($this->sessionControlService->checkActiveSessions($user->getEmail()) || $user->isAdmin()) {
  32.                 $this->licenseService->contentsWithLicensesOrGifts($user);
  33.             }
  34.             if ($this->sessionControlService->checkTimedoutSessions($user->getEmail())) {
  35.                 return $this->render(
  36.                     'panel/timedout.html.twig',
  37.                     []
  38.                 );
  39.             }
  40.             if ($user->getStatus() == User::STATUS_SUSPENDED) {
  41.                 return $this->render(
  42.                     'panel/disabled.html.twig',
  43.                     []
  44.                 );
  45.             }
  46.         }
  47.         $em $doctrine->getManager();
  48.         $settingsRepository $em->getRepository(Settings::class);
  49.         $allowregister $settingsRepository->findOneByName('allowregister');
  50.         $sessionid 0;
  51.         $request $this->requestStack->getCurrentRequest();
  52.         if ($request && $request->hasSession()) {
  53.             $session $request->getSession();
  54.             $sessionid $session->getId();
  55.         }
  56.         return $this->render('home/index.html.twig', [
  57.             'allowregister' => (!is_null($allowregister) && $allowregister->getValue() == 1),
  58.             'sessionid' => $sessionid
  59.         ]);
  60.     }
  61. }