Deprecated: Symfony\Component\Translation\t(): Implicitly marking parameter $domain as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/t/taurushr/vendor/symfony/translation/Resources/functions.php on line 18

Deprecated: Symfony\Component\Dotenv\Dotenv::loadEnv(): Implicitly marking parameter $envKey as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/t/taurushr/vendor/symfony/dotenv/Dotenv.php on line 110

Deprecated: Symfony\Component\Runtime\GenericRuntime::getResolver(): Implicitly marking parameter $reflector as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/t/taurushr/vendor/symfony/runtime/GenericRuntime.php on line 89

Deprecated: Symfony\Component\Runtime\RuntimeInterface::getResolver(): Implicitly marking parameter $reflector as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/t/taurushr/vendor/symfony/runtime/RuntimeInterface.php on line 26

Deprecated: Symfony\Component\Console\Input\ArgvInput::__construct(): Implicitly marking parameter $argv as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/t/taurushr/vendor/symfony/console/Input/ArgvInput.php on line 46

Deprecated: Symfony\Component\Console\Input\ArgvInput::__construct(): Implicitly marking parameter $definition as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/t/taurushr/vendor/symfony/console/Input/ArgvInput.php on line 46

Deprecated: Symfony\Component\Console\Input\Input::__construct(): Implicitly marking parameter $definition as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/t/taurushr/vendor/symfony/console/Input/Input.php on line 36

Deprecated: Constant E_STRICT is deprecated in /var/www/html/t/taurushr/vendor/symfony/error-handler/ErrorHandler.php on line 58

Deprecated: Constant E_STRICT is deprecated in /var/www/html/t/taurushr/vendor/symfony/error-handler/ErrorHandler.php on line 76
Symfony Profiler

src/Controller/AccreditationController.php line 111

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Accreditation;
  4. use App\Form\AccreditationType;
  5. use App\Annotation\CmsAdminDash;
  6. use App\Annotation\CmsComponent;
  7. use Doctrine\ORM\EntityManagerInterface;
  8. use App\Repository\AccreditationRepository;
  9. use Knp\Component\Pager\PaginatorInterface;
  10. use Symfony\Component\HttpFoundation\Request;
  11. use Symfony\Component\HttpFoundation\Response;
  12. use Symfony\Component\Routing\Annotation\Route;
  13. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  14. #[Route('/takeflight/accreditation')]
  15. class AccreditationController extends AbstractController
  16. {
  17.     /**
  18.      * @CmsAdminDash("Accreditations", active=true, routeName="app_accreditation_index", icon="fa fa-certificate", menuPosition=40, parentRouteName="control_content_index")
  19.      */
  20.     #[Route('/'name'app_accreditation_index'methods: ['GET'])]
  21.     public function index(AccreditationRepository $accreditationRepository): Response
  22.     {
  23.         return $this->render('accreditation/index.html.twig', [
  24.             'accreditations' => $accreditationRepository->findBy(['deleted' => false]),
  25.         ]);
  26.     }
  27.     #[Route('/new'name'app_accreditation_new'methods: ['GET''POST'])]
  28.     public function new(Request $request): Response
  29.     {
  30.         $accreditation = new Accreditation();
  31.         $form $this->createForm(AccreditationType::class, $accreditation);
  32.         $form->handleRequest($request);
  33.         if ($form->isSubmitted() && $form->isValid()) {
  34.             // REQUIRED IF USING UPLOAD FILE TRAIT
  35.             // $accreditation->uploadFile();
  36.             $entityManager $this->getDoctrine()->getManager();
  37.             $entityManager->persist($accreditation);
  38.             $entityManager->flush();
  39.             return $this->redirectToRoute('app_accreditation_index', [], Response::HTTP_SEE_OTHER);
  40.         }
  41.         return $this->render('accreditation/new.html.twig', [
  42.             'accreditation' => $accreditation,
  43.             'form' => $form->createView(),
  44.         ]);
  45.     }
  46.     #[Route('/{id}'name'app_accreditation_show'methods: ['GET'])]
  47.     public function show(Accreditation $accreditation): Response
  48.     {
  49.         return $this->render('accreditation/show.html.twig', [
  50.             'accreditation' => $accreditation,
  51.         ]);
  52.     }
  53.     #[Route('/{id}/edit'name'app_accreditation_edit'methods: ['GET''POST'])]
  54.     public function edit(Request $requestAccreditation $accreditation): Response
  55.     {
  56.         $form $this->createForm(AccreditationType::class, $accreditation);
  57.         $form->handleRequest($request);
  58.         if ($form->isSubmitted() && $form->isValid()) {
  59.             // REQUIRED IF USING UPLOAD FILE TRAIT
  60.             // $accreditation->uploadFile();
  61.             $this->getDoctrine()->getManager()->flush();
  62.             return $this->redirectToRoute('app_accreditation_index', [], Response::HTTP_SEE_OTHER);
  63.         }
  64.         return $this->render('accreditation/edit.html.twig', [
  65.             'accreditation' => $accreditation,
  66.             'form' => $form->createView(),
  67.         ]);
  68.     }
  69.     #[Route('/{id}'name'app_accreditation_delete'methods: ['POST'])]
  70.     public function delete(Request $requestAccreditation $accreditation): Response
  71.     {
  72.         if ($this->isCsrfTokenValid('delete'.$accreditation->getId(), $request->request->get('_token'))) {
  73.             $entityManager $this->getDoctrine()->getManager();
  74.             $accreditation->setActive(false);
  75.             $accreditation->setDeleted(true);
  76.             $entityManager->persist($accreditation);
  77.             $entityManager->flush();
  78.             $this->addFlash('success''Success - Accreditation deleted');
  79.         }
  80.         return $this->redirectToRoute('app_accreditation_index', [], Response::HTTP_SEE_OTHER);
  81.     }
  82.     /**
  83.      * @CmsComponent("Accreditations (All)", active=true, routeName="embed_accreditations_all")
  84.      *
  85.      * @param mixed $request
  86.      */
  87.     #[Route(path'/test-accreditations/all'name'embed_accreditations_all')]
  88.     public function embedAccreditationsAll(EntityManagerInterface $emPaginatorInterface $paginatorRequest $request): Response
  89.     {
  90.         $perpage 10;
  91.         $query $em->createQuery('SELECT e FROM App:Accreditation e WHERE e.deleted = 0 AND e.active = 1 ORDER BY e.sortOrder ASC');
  92.         $paginatedAccreditations $paginator->paginate($query$request->query->getInt('page'1), $perpage);
  93.         return $this->render('@theme/accreditation/accreditations.html.twig', [
  94.             'accreditations' => $paginatedAccreditations,
  95.         ]);
  96.     }
  97.     /**
  98.      * @CmsComponent("Accreditations (Featured Only)", active=true, routeName="embed_accreditations_featured")
  99.      *
  100.      * @param mixed $request
  101.      */
  102.     #[Route(path'/test-accreditations/featured'name'embed_accreditations_featured')]
  103.     public function embedAccreditationsFeatured(EntityManagerInterface $emPaginatorInterface $paginatorRequest $request): Response
  104.     {
  105.         $perpage 10;
  106.         $query $em->createQuery('SELECT e FROM App:Accreditation e WHERE e.deleted = 0 AND e.active = 1 AND e.featured = 1 ORDER BY e.sortOrder ASC');
  107.         $paginatedAccreditations $paginator->paginate($query$request->query->getInt('page'1), $perpage);
  108.         return $this->render('@theme/accreditation/featured.html.twig', [
  109.             'accreditations' => $paginatedAccreditations,
  110.         ]);
  111.     }
  112. }