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

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 removeDomainFromPermalink($permalink)
  43.     {
  44.         /// Remove the domain from the permalink. We should improve this in the future.
  45.         $permalink str_replace("https://www.startplatz.de"""$permalink);
  46.         $permalink str_replace("http://dev.startplatz.de"""$permalink);
  47.         $permalink str_replace("https://www.staging.startplatz.de"""$permalink);
  48.         if ($permalink == ''$permalink "/";
  49.         return $permalink;
  50.     }
  51.     public function getLanguageByPermalink($permalink)
  52.     {
  53.         if (str_ends_with($permalink"/fr") || str_contains($permalink"/fr/")) {
  54.             return "FR";
  55.         } elseif (str_ends_with($permalink"/en") || str_contains($permalink"/en/")) {
  56.             return "EN";
  57.         } else {
  58.             return "DE";
  59.         }
  60.     }
  61.     /**
  62.      */
  63.     public function menuBootstrap40Action($permalinkRequest $request)
  64.     {
  65.         $lang $this->getLanguageByPermalink($permalink);
  66.         $targetPath $this->removeDomainFromPermalink($permalink);
  67.         return $this->render('@StartPlatzStyleBundle/Navigation/_nav.homepage.bootstrap4.html.twig', [
  68.             'menuLinksAndPhrases' => $this->menuTranslationService->getMenuLinksAndPhrases($targetPath$lang),
  69.             'targetPath' => $targetPath,
  70.             'permaLink' => $permalink,
  71.             'lang' => $lang,
  72.         ]);
  73.     }
  74.     /**
  75.      */
  76.     public function homepageCssAction($template '_homepage.version-2021-winter')
  77.     {
  78.         return $this->render("@StartPlatzStyleBundle/CSS/{$template}.html.twig", []);
  79.     }
  80.     /**
  81.      */
  82.     public function menuAction($permalink "/")
  83.     {
  84.         $targetPath str_replace('http://dev.startplatz.de'''str_replace('https://www.startplatz.de'''str_replace('http://127.0.0.1:9999''', (string)$permalink)));
  85.         if ($targetPath == '') {
  86.             $targetPath "/";
  87.         }
  88.         $lang "DE";
  89.         return $this->render('@StartPlatzWebsiteBundle/Default/menu.html.twig', [
  90.             'menuLinksAndPhrases' => $this->menuTranslationService->getMenuLinksAndPhrases($targetPath$lang),
  91.         ]);
  92.     }
  93.     /**
  94.      */
  95.     public function menuEnAction($permalinkRequest $request)
  96.     {
  97.         $targetPath str_replace('http://dev.startplatz.de'''str_replace('https://www.startplatz.de'''str_replace('http://127.0.0.1:9999''', (string)$permalink)));
  98.         if ($targetPath == '') {
  99.             $targetPath "/";
  100.         }
  101.         return $this->render('@StartPlatzWebsiteBundle/Default/menuEn.html.twig', [
  102.             'menuLinksAndPhrases' => $this->menuTranslationService->getMenuLinksAndPhrases($targetPath'EN'),
  103.         ]);
  104.     }
  105. }