<?php declare(strict_types=1);
namespace App\StartPlatz\Bundle\WebsiteBundle\Controller;
use App\StartPlatz\Bundle\UserBundle\Entity\User;
use App\StartPlatz\Bundle\WebsiteBundle\MenuTranslationService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
class DefaultController extends AbstractController
{
public function __construct(private readonly MenuTranslationService $menuTranslationService)
{
}
public function indexAction($name)
{
return $this->render('@StartPlatzWebsiteBundle/Default/index.html.twig', ['name' => $name]);
}
/**
*/
public function footerAction(Request $request)
{
$targetPath = $request->server->get('REDIRECT_URL');
$lang = $this->menuTranslationService->getLang($targetPath);
return $this->render('@StartPlatzWebsiteBundle/Default/footer.html.twig', [
'templateVars' => [],
'lang' => $lang,
'footerPhrases' => $this->menuTranslationService->getFooterPhrases($lang),
'footerLinks' => $this->menuTranslationService->getFooterLinks($lang),
]);
}
/**
* @Route("_footer", name="_footer")
*/
public function footerBootstrap40Action(Request $request)
{
$targetPath = $request->server->get('REDIRECT_URL');
$lang = $this->menuTranslationService->getLang($targetPath);
return $this->render('@StartPlatzWebsiteBundle/Default/footerBootstrap40.html.twig', [
'templateVars' => [],
'lang' => $lang,
'footerPhrases' => $this->menuTranslationService->getFooterPhrases($lang),
'footerLinks' => $this->menuTranslationService->getFooterLinks($lang),
]);
}
public function removeDomainFromPermalink($permalink)
{
/// Remove the domain from the permalink. We should improve this in the future.
$permalink = str_replace("https://www.startplatz.de", "", $permalink);
$permalink = str_replace("http://dev.startplatz.de", "", $permalink);
$permalink = str_replace("https://www.staging.startplatz.de", "", $permalink);
if ($permalink == '') $permalink = "/";
return $permalink;
}
public function getLanguageByPermalink($permalink)
{
if (str_ends_with($permalink, "/fr") || str_contains($permalink, "/fr/")) {
return "FR";
} elseif (str_ends_with($permalink, "/en") || str_contains($permalink, "/en/")) {
return "EN";
} else {
return "DE";
}
}
/**
*/
public function menuBootstrap40Action($permalink, Request $request)
{
$lang = $this->getLanguageByPermalink($permalink);
$targetPath = $this->removeDomainFromPermalink($permalink);
return $this->render('@StartPlatzStyleBundle/Navigation/_nav.homepage.bootstrap4.html.twig', [
'menuLinksAndPhrases' => $this->menuTranslationService->getMenuLinksAndPhrases($targetPath, $lang),
'targetPath' => $targetPath,
'permaLink' => $permalink,
'lang' => $lang,
]);
}
/**
*/
public function homepageCssAction($template = '_homepage.version-2021-winter')
{
return $this->render("@StartPlatzStyleBundle/CSS/{$template}.html.twig", []);
}
/**
*/
public function menuAction($permalink = "/")
{
$targetPath = str_replace('http://dev.startplatz.de', '', str_replace('https://www.startplatz.de', '', str_replace('http://127.0.0.1:9999', '', (string)$permalink)));
if ($targetPath == '') {
$targetPath = "/";
}
$lang = "DE";
return $this->render('@StartPlatzWebsiteBundle/Default/menu.html.twig', [
'menuLinksAndPhrases' => $this->menuTranslationService->getMenuLinksAndPhrases($targetPath, $lang),
]);
}
/**
*/
public function menuEnAction($permalink, Request $request)
{
$targetPath = str_replace('http://dev.startplatz.de', '', str_replace('https://www.startplatz.de', '', str_replace('http://127.0.0.1:9999', '', (string)$permalink)));
if ($targetPath == '') {
$targetPath = "/";
}
return $this->render('@StartPlatzWebsiteBundle/Default/menuEn.html.twig', [
'menuLinksAndPhrases' => $this->menuTranslationService->getMenuLinksAndPhrases($targetPath, 'EN'),
]);
}
}