src/Controller/Front/RequestController.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Front;
  3. use App\Entity\User\User;
  4. use App\Controller\Admin\CoreController;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. use App\Repository\Configuration\SurveyRepository;
  9. use App\Service\LanguagesManager;
  10. use App\Service\Manager\RequestForm\RequestFormManager;
  11. #[Route('/request')]
  12. class RequestController extends CoreController
  13. {
  14.     #[Route('/index/{refSuffix}'name'front_request_index')]
  15.     public function index($refSuffix
  16.                             SurveyRepository $surveyRepository
  17.                             Request $request
  18.                             LanguagesManager $languagesManager,
  19.                             RequestFormManager $requestFormManager
  20.                             ): Response
  21.     {
  22.         $language $languagesManager->getLanguageUser($request);
  23.         $survey =  "";
  24.         $user $this->getUser();
  25.         $parametres = [
  26.             'refSuffix' => $refSuffix,
  27.             'deletedAt' => null,
  28.             'isEnable' => 1,
  29.             'isDisplay' => 1
  30.         ];
  31.         if ($user && (!in_array($user->getRoles(), [User::ROLE_ADMIN]))) {
  32.             unset($parametres['isEnable']);
  33.             unset($parametres['isDisplay']);
  34.         }
  35.         $survey $surveyRepository->getAllQb([
  36.             'refSuffix' => $refSuffix,
  37.             'fk' => ['survey.label'],
  38.             'id_language' => $language->getId()
  39.             ])->getOneOrNullResult();
  40.       
  41.         $response =  $requestFormManager->getForm($survey);
  42.         if($response instanceof Response) return $response
  43.         return $this->render('front/request/index.html.twig', (!empty($response['paramsTemplate'])) ? $response['paramsTemplate'] : [] );
  44.     }
  45.  
  46. }