src/StartPlatz/Bundle/WebsiteBundle/Controller/DefaultController.php line 115

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace App\StartPlatz\Bundle\WebsiteBundle\Controller;
  3. use App\StartPlatz\Bundle\UserBundle\Entity\User;
  4. use App\StartPlatz\Bundle\WebsiteBundle\MenuTranslationService;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. class DefaultController extends AbstractController
  9. {
  10.     public function __construct(private readonly MenuTranslationService $menuTranslationService)
  11.     {
  12.     }
  13.     public function indexAction($name)
  14.     {
  15.         return $this->render('@StartPlatzWebsiteBundle/Default/index.html.twig', ['name' => $name]);
  16.     }
  17.     /**
  18.      */
  19.     public function footerAction(Request $request)
  20.     {
  21.         $targetPath $request->server->get('REDIRECT_URL');
  22.         $lang $this->menuTranslationService->getLang($targetPath);
  23.         return $this->render('@StartPlatzWebsiteBundle/Default/footer.html.twig', [
  24.             'templateVars' => [],
  25.             'lang' => $lang,
  26.             'footerPhrases' => $this->menuTranslationService->getFooterPhrases($lang),
  27.             'footerLinks' => $this->menuTranslationService->getFooterLinks($lang),
  28.         ]);
  29.     }
  30.     #[Route('_footer'name'_footer')]
  31.     public function footerBootstrap40Action(Request $request)
  32.     {
  33.         $targetPath $request->server->get('REDIRECT_URL');
  34.         $lang $this->menuTranslationService->getLang($targetPath);
  35.         return $this->render('@StartPlatzWebsiteBundle/Default/footerBootstrap40.html.twig', [
  36.             'templateVars' => [],
  37.             'lang' => $lang,
  38.             'footerPhrases' => $this->menuTranslationService->getFooterPhrases($lang),
  39.             'footerLinks' => $this->menuTranslationService->getFooterLinks($lang),
  40.         ]);
  41.     }
  42.     public function footerTailwindAction($permalink '/'Request $request)
  43.     {
  44.         $lang $this->getLanguageByPermalink($permalink);
  45.         $targetPath $this->removeDomainFromPermalink($permalink);
  46.         return $this->render('@StartPlatzWebsiteBundle/Default/footer.tailwind.html.twig', [
  47.             'menuLinksAndPhrases' => $this->menuTranslationService->getMenuLinksAndPhrases($targetPath$lang),
  48.             'targetPath' => $targetPath,
  49.             'lang' => $lang,
  50.         ]);
  51.     }
  52.     public function removeDomainFromPermalink($permalink)
  53.     {
  54.         /// Remove the domain from the permalink. We should improve this in the future.
  55.         $permalink str_replace("https://www.startplatz.de"""$permalink);
  56.         $permalink str_replace("http://dev.startplatz.de"""$permalink);
  57.         $permalink str_replace("https://www.staging.startplatz.de"""$permalink);
  58.         if ($permalink == ''$permalink "/";
  59.         return $permalink;
  60.     }
  61.     public function getLanguageByPermalink($permalink)
  62.     {
  63.         if (str_ends_with($permalink"/fr") || str_contains($permalink"/fr/")) {
  64.             return "FR";
  65.         } elseif (str_ends_with($permalink"/en") || str_contains($permalink"/en/")) {
  66.             return "EN";
  67.         } else {
  68.             return "DE";
  69.         }
  70.     }
  71.     /**
  72.      */
  73.     public function menuBootstrap40Action($permalinkRequest $request)
  74.     {
  75.         $lang $this->getLanguageByPermalink($permalink);
  76.         $targetPath $this->removeDomainFromPermalink($permalink);
  77.         return $this->render('@StartPlatzStyleBundle/Navigation/_nav.homepage.bootstrap4.html.twig', [
  78.             'menuLinksAndPhrases' => $this->menuTranslationService->getMenuLinksAndPhrases($targetPath$lang),
  79.             'targetPath' => $targetPath,
  80.             'permaLink' => $permalink,
  81.             'lang' => $lang,
  82.         ]);
  83.     }
  84.     public function menuTailwindAction($permalinkRequest $request)
  85.     {
  86.         $lang $this->getLanguageByPermalink($permalink);
  87.         $targetPath $this->removeDomainFromPermalink($permalink);
  88.         return $this->render('@StartPlatzStyleBundle/Navigation/_nav.public.tailwind.html.twig', [
  89.             'menuLinksAndPhrases' => $this->menuTranslationService->getMenuLinksAndPhrases($targetPath$lang),
  90.             'targetPath' => $targetPath,
  91.             'permaLink' => $permalink,
  92.             'lang' => $lang,
  93.         ]);
  94.     }
  95.     /**
  96.      */
  97.     public function homepageCssAction($template '_homepage.version-2021-winter')
  98.     {
  99.         return $this->render("@StartPlatzStyleBundle/CSS/{$template}.html.twig", []);
  100.     }
  101.     /**
  102.      */
  103.     public function menuAction($permalink "/")
  104.     {
  105.         $targetPath str_replace('http://dev.startplatz.de'''str_replace('https://www.startplatz.de'''str_replace('http://127.0.0.1:9999''', (string)$permalink)));
  106.         if ($targetPath == '') {
  107.             $targetPath "/";
  108.         }
  109.         $lang "DE";
  110.         return $this->render('@StartPlatzWebsiteBundle/Default/menu.html.twig', [
  111.             'menuLinksAndPhrases' => $this->menuTranslationService->getMenuLinksAndPhrases($targetPath$lang),
  112.         ]);
  113.     }
  114.     /**
  115.      */
  116.     public function menuEnAction($permalinkRequest $request)
  117.     {
  118.         $targetPath str_replace('http://dev.startplatz.de'''str_replace('https://www.startplatz.de'''str_replace('http://127.0.0.1:9999''', (string)$permalink)));
  119.         if ($targetPath == '') {
  120.             $targetPath "/";
  121.         }
  122.         return $this->render('@StartPlatzWebsiteBundle/Default/menuEn.html.twig', [
  123.             'menuLinksAndPhrases' => $this->menuTranslationService->getMenuLinksAndPhrases($targetPath'EN'),
  124.         ]);
  125.     }
  126. }