src/Controller/FrontendBundle/FrontpageController.php line 48

Open in your IDE?
  1. <?php
  2. namespace App\Controller\FrontendBundle;
  3. use Doctrine\ORM\EntityManagerInterface;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\HttpFoundation\Session\Session;
  9. use App\BackendBundle\Helper\BoPartnerHelper;
  10. use App\BackendBundle\Helper\CompanyHelper;
  11. use App\BackendBundle\Helper\SecurityHelper;
  12. use App\BackendBundle\Helper\SchoolHelper;
  13. use App\BackendBundle\Helper\SchoolClassHelper;
  14. use App\BackendBundle\Helper\SiteTitleHelper;
  15. use App\BackendBundle\Helper\ScoreHelper;
  16. use App\Entity\SchoolClass;
  17. class FrontpageController extends AbstractController {
  18.     private $em;
  19.     private $boHelper;
  20.     private $companyHelper;
  21.     private $siteTitleHelper;
  22.     private $securityHelper;
  23.     private $scoreHelper;
  24.     private $schoolHelper;
  25.     private $schoolClassHelper;
  26.     public function __construct(SiteTitleHelper $sitehelperSecurityHelper $securityhelperSchoolHelper $schoolhelper,
  27.             SchoolClassHelper $schoolclasshelperScoreHelper $scorehelperEntityManagerInterface $emCompanyHelper $companyHelper,
  28.             BoPartnerHelper $boPartnerHelper) {
  29.         $this->boHelper $boPartnerHelper;
  30.         $this->companyHelper $companyHelper;
  31.         $this->em $em;
  32.         $this->siteTitleHelper $sitehelper;
  33.         $this->securityHelper $securityhelper;
  34.         $this->schoolClassHelper $schoolclasshelper;
  35.         $this->schoolHelper $schoolhelper;
  36.         $this->scoreHelper $scorehelper;
  37.     }
  38.     /**
  39.      * @return \Symfony\Component\HttpFoundation\Response
  40.      * @Route("/", name="frontpage_public", defaults={"title": "Die Welt der Berufe entdecken", "description": "berufsreise.at ist die größte Online-Plattform zum Thema Berufsorientierung in Tirol. Entdecke spannende Berufe, lerne Tiroler Unternehmen, BO-Institutionen und weiterführende Schulen kennen oder begleite Tiroler Lehrlinge und Schüler*innen in deren Ausbildungen!"}) 
  41.      */
  42.     public function publicAction(Request $request) {
  43.         $this->siteTitleHelper->setTitleDescription($request);
  44.         return $this->render('@frontend/public/frontpage.html.twig');
  45.     }
  46.     
  47.     private function getSliderItems() {
  48.         $query "SELECT si FROM \App\Entity\SliderItem si "
  49.                 "WHERE (si.showAfter is NULL OR CURRENT_TIMESTAMP() >= si.showAfter) AND "
  50.                 "(si.showUntil is NULL or si.showUntil >= CURRENT_TIMESTAMP()) "
  51.                 "ORDER BY si.position ASC";
  52.         /* @var $dql_query Query */
  53.         $dql_query $this->em->createQuery($query);
  54.         $sliderItems $dql_query->getResult();
  55.         return $sliderItems;
  56.     }
  57.     /**
  58.      * @return \Symfony\Component\HttpFoundation\Response
  59.      * @Route("/meine-berufsreise", name="frontpage_private") 
  60.      */
  61.     public function privateAction(Request $request) {
  62.         return $this->redirectToRoute('security_login_redirect');
  63.     }
  64.     /**
  65.      * @return \Symfony\Component\HttpFoundation\Response
  66.      * @Route("/bopartner", name="bopartner_default_private") 
  67.      */
  68.     public function boPartnerAction() {
  69.         $user $this->getUser();
  70.         /* @var $profile BoPartnerProfile */
  71.         $profile $this->boHelper->getSelectedBoPartnerProfileByUser($user);
  72.         if ($profile == null) {
  73.             throw new NotFoundHttpException();
  74.         }
  75.         $this->securityHelper->authenticateByRoles($user, array('ROLE_BOPARTNER'));
  76.         return $this->render('@frontend/private/bopartner/frontpage.html.twig', array(
  77.                     'profile' => $profile
  78.         ));
  79.     }
  80.     /**
  81.      * @return \Symfony\Component\HttpFoundation\Response
  82.      * @Route("/unternehmen", name="company_default_private") 
  83.      */
  84.     public function companyAction() {
  85.         $user $this->getUser();
  86.         /* @var $companyProfile CompanyProfile */
  87.         $companyProfile $this->companyHelper->getSelectedCompanyProfileByUser($user);
  88.         if ($companyProfile == null) {
  89.             throw new NotFoundHttpException();
  90.         }
  91.         $this->securityHelper->authenticateByRoles($user, array('ROLE_COMPANY'));
  92.         return $this->render('@frontend/private/company/frontpage.html.twig', array(
  93.                     'profile' => $companyProfile
  94.         ));
  95.     }
  96.     /**
  97.      * @return \Symfony\Component\HttpFoundation\Response
  98.      * @Route("/schule", name="school_default_private") 
  99.      */
  100.     public function schoolAction() {
  101.         $user $this->getUser();
  102.         /* @var $schoolProfile SchoolProfile */
  103.         $schoolProfile $this->schoolHelper->getSelectedSchoolProfileByUser($user);
  104.         if ($schoolProfile == null) {
  105.             throw new NotFoundHttpException();
  106.         }
  107.         $this->securityHelper->authenticateByRoles($user, array('ROLE_SECONDARY_SCHOOL'));
  108.         return $this->render('@frontend/private/school/frontpage.html.twig', array(
  109.                     'profile' => $schoolProfile
  110.         ));
  111.     }
  112.     /**
  113.      * @return \Symfony\Component\HttpFoundation\Response
  114.      * @Route("/schulklasse", name="school_class_default_private") 
  115.      */
  116.     public function schoolClassAction() {
  117.         $user $this->getUser();
  118.         $this->securityHelper->authenticateByRoles($user, array('ROLE_SCHOOL_CLASS'));
  119.         $schoolClass $this->schoolClassHelper->getSchoolClassBySchoolClassUser($user);
  120.         /* @var $schoolClass SchoolClass */
  121.         $schoolClassUser $schoolClass->getSchoolClassUser();
  122.         $isDemoClass false;
  123.         if ($schoolClassUser->getEmail() == "demoSchoolClass@test.test") {
  124.             $isDemoClass true;
  125.         }
  126.         $pointsBooking $this->scoreHelper->getSchoolClassTotalScoreByTypeID($schoolClass2);
  127.         $pointsPreparationAndFeedback $this->scoreHelper->getSchoolClassTotalScoreByTypeID($schoolClass4);
  128.         $pointsKlickThePic $this->scoreHelper->getSchoolClassTotalScoreByTypeID($schoolClass3);
  129.         $pointsKannstDuPunkten $this->scoreHelper->getSchoolClassTotalScoreByTypeID($schoolClass5);
  130.         $pointsLebenslaufGame $this->scoreHelper->getSchoolClassTotalScoreByTypeID($schoolClass7);
  131.         $pointsAnschreibenGame $this->scoreHelper->getSchoolClassTotalScoreByTypeID($schoolClass8);
  132.         $pointsStellenanzeigeGame $this->scoreHelper->getSchoolClassTotalScoreByTypeID($schoolClass9);
  133.         $pointsBewerbungsknigge $this->scoreHelper->getSchoolClassTotalScoreByTypeID($schoolClass10);
  134.         $pointsAwards $this->scoreHelper->getSchoolClassTotalScoreByTypeID($schoolClass11);
  135.         $startDate = new \DateTime('2021-03-08 08:00');
  136.         $endDate = new \DateTime('2021-03-28 23:59');
  137.         $pointsFilteredAllArray $this->scoreHelper->getScoresBySchoolClassAndDateRange($schoolClass$startDate$endDate);
  138.         $pointsFilteredAll 0;
  139.         foreach ($pointsFilteredAllArray as $entry) {
  140.             $pointsFilteredAll += $entry->getPoints();
  141.         }
  142.         if ($pointsBooking == null) {
  143.             $pointsBooking 0;
  144.         }
  145.         if ($pointsPreparationAndFeedback == null) {
  146.             $pointsPreparationAndFeedback 0;
  147.         }
  148.         if ($pointsKlickThePic == null) {
  149.             $pointsKlickThePic 0;
  150.         }
  151.         if ($pointsKannstDuPunkten == null) {
  152.             $pointsKannstDuPunkten 0;
  153.         }
  154.         if ($pointsLebenslaufGame == null) {
  155.             $pointsLebenslaufGame 0;
  156.         }
  157.         if ($pointsAnschreibenGame == null) {
  158.             $pointsAnschreibenGame 0;
  159.         }
  160.         if ($pointsStellenanzeigeGame == null) {
  161.             $pointsStellenanzeigeGame 0;
  162.         }
  163.         if ($pointsBewerbungsknigge == null) {
  164.             $pointsBewerbungsknigge 0;
  165.         }
  166.         if ($pointsAwards == null) {
  167.             $pointsAwards 0;
  168.         }
  169.         return $this->render('@frontend/private/school_class/frontpage.html.twig', array(
  170.                     "schoolClass" => $schoolClass,
  171.                     'pointsBooking' => $pointsBooking,
  172.                     'pointsPreparationAndFeedback' => $pointsPreparationAndFeedback,
  173.                     'pointsKlickThePic' => $pointsKlickThePic,
  174.                     'pointsKannstDuPunkten' => $pointsKannstDuPunkten,
  175.                     'pointsLebenslaufGame' => $pointsLebenslaufGame,
  176.                     'pointsAnschreibenGame' => $pointsAnschreibenGame,
  177.                     'pointsStellenanzeigeGame' => $pointsStellenanzeigeGame,
  178.                     'pointsBewerbungsknigge' => $pointsBewerbungsknigge,
  179.                     'pointsAwards' => $pointsAwards,
  180.                     'pointsFilteredAll' => $pointsFilteredAll,
  181.                     'pointsFilteredAllStartDate' => $startDate,
  182.                     'pointsFilteredAllEndDate' => $endDate,
  183.                     'dateNow' => new \DateTime(),
  184.                     'isDemoClass' => $isDemoClass,
  185.         ));
  186.     }
  187.     /**
  188.      * @return \Symfony\Component\HttpFoundation\Response
  189.      * @Route("/niederoesterreich", name="lower_austria_default_private") 
  190.      */
  191.     public function lowerAustriaAction() {
  192.         $user $this->getUser();
  193.         $this->securityHelper->authenticateByRoles($user, array('ROLE_LOWER_AUSTRIA_SCHOOL_CLASS'));
  194.         $schoolClass $this->schoolClassHelper->getSchoolClassBySchoolClassUser($user);
  195.         return $this->render('@frontend/private/lower_austria/frontpage.html.twig', array(
  196.                     "schoolClass" => $schoolClass,
  197.                     'dateNow' => new \DateTime(),
  198.         ));
  199.     }
  200.     /**
  201.      * @return \Symfony\Component\HttpFoundation\Response
  202.      * @Route("/schulklasse/bewerbungswelt", name="school_class_application_categories") 
  203.      */
  204.     public function schoolClassApplicationCategoriesAction() {
  205.         return $this->render('@frontend/private/school_class/application_categories.html.twig');
  206.     }
  207.     /**
  208.      * @return \Symfony\Component\HttpFoundation\Response
  209.      * @Route("/lehrer", name="teacher_default_private") 
  210.      */
  211.     public function teacherAction(Session $session) {
  212.         if ($session->has('redirect_appointment')) {
  213.             $appointmentID intval($session->get('redirect_appointment'));
  214.             return $this->redirectToRoute('event_booking_view', array('appointmentId' => $appointmentID));
  215.         }
  216.         $user $this->getUser();
  217.         $this->securityHelper->authenticateByRoles($user, array('ROLE_TEACHER'));
  218.         $school $this->schoolHelper->getSchoolByTeacher($user);
  219.         // the mapping of the current active Teacher
  220.         $role "";
  221.         if ($school != null) {
  222.             $schoolTeacherMapping $this->schoolHelper->getSchoolTeacherMapping($user$school);
  223.             if ($this->schoolHelper->hasSchoolRole('ROLE_TEACHER_BO'$schoolTeacherMapping)) {
  224.                 $role 'ROLE_TEACHER_BO';
  225.             } else {
  226.                 $role 'ROLE_TEACHER_KV';
  227.             }
  228.         }
  229.         return $this->render('@frontend/private/teacher/frontpage.html.twig', array(
  230.                     'role' => $role
  231.         ));
  232.     }
  233.     /**
  234.      * @return \Symfony\Component\HttpFoundation\Response
  235.      * @Route("/direktoren", name="director_default_private") 
  236.      */
  237.     public function directorAction() {
  238.         $user $this->getUser();
  239.         $this->securityHelper->authenticateByRoles($user, array('ROLE_DIRECTOR'));
  240.         return $this->render('@frontend/private/director/frontpage.html.twig', array());
  241.     }
  242.     /**
  243.      * @return \Symfony\Component\HttpFoundation\Response
  244.      */
  245.     public function restrictedAction() {
  246.         return $this->render('@frontend/full/frontpage.html.twig', array(
  247.                     'name' => 'private frontpage'
  248.         ));
  249.     }
  250. }