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

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