src/Controller/AppsController.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Client;
  4. use Symfony\Component\HttpFoundation\Request;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Component\HttpFoundation\RedirectResponse;
  7. use Symfony\Contracts\Translation\TranslatorInterface;
  8. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  9. class AppsController extends AbstractController
  10. {
  11.   private $Lo_Client;
  12.   private $Lo_Translator;
  13.   public function __construct(TranslatorInterface $translatorClient $client){
  14.     $this->Lo_Client $client;
  15.     $this->Lo_Translator $translator;
  16.   }
  17.   /**
  18.     * @Route("/", name="app_root")
  19.     */
  20.   public function index()
  21.   {
  22.     if ($this->getUser()) return $this->redirectToRoute('app_home', ['_locale' => 'de']);
  23.     else return $this->redirectToRoute('app_login', ['_locale' => 'de']);
  24.   }
  25.   /**
  26.   * @Route("/{_locale<%app.supported_locales%>}/apps", name="app_home")
  27.   */
  28.   public function apps()
  29.   {
  30.     $Lb_UserHasRoles false;
  31.     $La_ClientCards=[];
  32.     $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  33.     $La_Roles $this->getUser()->getRoles();
  34.     $Li_AmountRoles count($this->getUser()->getRoles());
  35.     $Lo_Data =  $this->Lo_Client->getAgentCompanies($this->getUser()->getPersonID(), $this->getUser()->getAddressRoleID(14));
  36.     if($Lo_Data->Error == 5) {
  37.       return new RedirectResponse('/logout');
  38.     }
  39.     else $La_Clients $Lo_Data->Result->ArrayData;
  40.     foreach ($La_Clients as $key => $Lo_Client) {
  41.       $La_ClientCards[] = [
  42.         'title' => $Lo_Client->s_Company,
  43.         'description' => $this->Lo_Translator->trans("webtool_client"),
  44.         'url' => 'app_agentclientstool',
  45.         'id' => $Lo_Client->i_AddressRoleID,
  46.         'agentAddressId' => $Lo_Client->i_AgentAddressID,
  47.         'image' => 'wert.jpg',
  48.         'role' => 'ROLE_CLIENT',
  49.         'i_AddressRoleID' => $this->getUser()->getAddressRoleID(14$Lo_Client->i_AgentAddressID)
  50.       ];
  51.     }
  52.     
  53.     if(!($Li_AmountRoles == && $La_Roles[0] == 'ROLE_USER')) $Lb_UserHasRoles true;
  54.     $La_DataTemplate = [
  55.       'controller_name' => 'AppsController',
  56.       'user_has_roles' => $Lb_UserHasRoles,
  57.       'cards' => [
  58.         'salestool' => [
  59.           'title' => $this->Lo_Translator->trans("webtool_sales"),
  60.           'description' => $this->Lo_Translator->trans("webtool_to_sale_courses"),
  61.           'url' => 'app_salestool',
  62.           'id' => $this->getUser()->getAddressRoleID(12),
  63.           'image' => 'kunden-anlocken.jpg',
  64.           'role' => 'ROLE_SALES',
  65.           'i_AddressRoleID' => $this->getUser()->getAddressRoleID(12)
  66.         ],
  67.         'member' => [
  68.           'title' => $this->Lo_Translator->trans("participant"),
  69.           'description' => $this->Lo_Translator->trans("webtool_participant"),
  70.           'url' => 'app_participantstool',
  71.           'id' => $this->getUser()->getAddressRoleID(2),
  72.           'image' => 'frau.jpg',
  73.           'role' => 'ROLE_PARTICIPANT',
  74.           'i_AddressRoleID' => $this->getUser()->getAddressRoleID(2)
  75.         ],
  76.         'instructor' => [
  77.           'title' => $this->Lo_Translator->trans("instructor"),
  78.           'description' => $this->Lo_Translator->trans("webtool_instructor"),
  79.           'url' => 'app_instructorstool',
  80.           'id' => $this->getUser()->getAddressRoleID(3),
  81.           'image' => 'webinar.jpg',
  82.           'role' => 'ROLE_INSTRUCTOR',
  83.           'i_AddressRoleID' => $this->getUser()->getAddressRoleID(3)
  84.         ],
  85.       ],
  86.     ];
  87.     $La_DataTemplate['cards'] = array_merge($La_DataTemplate['cards'], $La_ClientCards);
  88.     return $this->render('apps/index.html.twig'$La_DataTemplate);
  89.   }
  90.   /**
  91.   * @Route("/{_locale<%app.supported_locales%>}/apps/{vue_route}", name="share", requirements={"vue_route"=".*"})
  92.   * @Route("/{_locale<%app.supported_locales%>}/apps/user/profile", name="app_userboard")
  93.   * @Route("/{_locale<%app.supported_locales%>}/apps/participantstool/{id}", name="app_participantstool", options={"expose"=true})
  94.   * @Route("/{_locale<%app.supported_locales%>}/apps/clientstool/{id}/{agentAddressId}", name="app_agentclientstool", options={"expose"=true})
  95.   * @Route("/{_locale<%app.supported_locales%>}/apps/salestool", name="app_salestool")
  96.   * @Route("/{_locale<%app.supported_locales%>}/apps/instructorstool/{id}", name="app_instructorstool", options={"expose"=true})
  97.   * @Route("/{_locale<%app.supported_locales%>}/apps/user/absences/{id}", name="app_userabsences")
  98.   */
  99.   public function vueRouting(Request $request)
  100.   {
  101.     $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
  102.     $Ls_BaseUrl $request->getScheme() . '://' $request->getHttpHost();
  103.     $La_DataTemplate = [
  104.       'controller_name' => 'AppsController',
  105.       'data' => [
  106.           'base_url' => $Ls_BaseUrl,
  107.           'vuei18n' => $this->getTranslations($request->getLocale()),
  108.           'locale' => $request->getLocale(),
  109.           'addressRoleID' => $request->query->get('addressRoleID'),
  110.           'roles' => implode(','$this->getUser()->getRoles()),
  111.           'properties' => $this->getUser()->getProperties()
  112.       ]
  113.     ];
  114.     return $this->render('apps/vue.html.twig'$La_DataTemplate);
  115.   }
  116.  /**
  117.   * @Route("/apps/{no_route}", name="no_route", requirements={"no_route"=".*"})
  118.   */
  119.   public function no_route()
  120.   {
  121.     if ($this->getUser()) return $this->redirectToRoute('app_home', ['_locale' => 'de']);
  122.     else return $this->redirectToRoute('app_login', ['_locale' => 'de']);
  123.   }
  124.   private function getTranslations($As_Locale){   
  125.     $catalogue $this->Lo_Translator->getCatalogue($As_Locale);
  126.     $Lo_VueI18n $catalogue->all();
  127.     while ($catalogue $catalogue->getFallbackCatalogue()) {
  128.         $Lo_VueI18n array_replace_recursive($catalogue->all(), $Lo_VueI18n);
  129.     } 
  130.     $new_dictionary = [
  131.       'word_english' => $this->Lo_Translator->trans('word_english'),
  132.     ];
  133.     return $Lo_VueI18n['messages'];
  134.   }
  135. }