Verified Commit 26cfc9d4 authored by Carl Schwan's avatar Carl Schwan 🚴
Browse files

add legalacy redirecter

parent 2611d14c
......@@ -10,6 +10,7 @@ namespace App\Controller;
use App\Model\AppData;
use App\Providers\ApplicationsProviderFile;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
......@@ -29,11 +30,16 @@ class MainController extends AbstractController
{
/**
* @Route("/{_locale}", name="app_main_index", requirements={"_locale": "%app.locales%"}, defaults={"_locale": "en"})
* @param Request $request
* @param string $_locale
* @param CdnCache $cdn
* @return Response
*/
public function index(string $_locale, CdnCache $cdn): Response
public function index(Request $request, string $_locale, CdnCache $cdn): Response
{
if ($request->query->get('site_locale')) {
return $this->redirectToRoute('app_main_index', ['_locale' => $request->query->get('site_locale')]);
}
$applicationsProvider = new ApplicationsProviderFile("index.json");
return $this->render('main/index.html.twig', [
......@@ -46,13 +52,17 @@ class MainController extends AbstractController
/**
* @Route("/{category}", defaults={"_locale": "en"})
* @Route("/{_locale}/{category}", name="app_main_category_intl", requirements={"_locale": "%app.locales%"})
* @param Request $request
* @param string $_locale
* @param string $category
* @param CdnCache $cdn
* @return Response
*/
public function category(string $_locale, string $category, CdnCache $cdn): Response
public function category(Request $request, string $_locale, string $category, CdnCache $cdn): Response
{
if ($request->query->get('site_locale')) {
return $this->redirectToRoute('app_main_category_intl', ['_locale' => $request->query->get('site_locale'), 'category' => $category]);
}
$applicationsProvider = new ApplicationsProviderFile("index.json");
return $this->render('main/category.html.twig', [
......@@ -65,14 +75,19 @@ class MainController extends AbstractController
/**
* @Route("/{category}/{application}", requirements={"_locale": "%app.locales%"}, defaults={"_locale": "en"})
* @Route("/{_locale}/{category}/{application}", name="app_main_application_intl", requirements={"_locale": "%app.locales%"})
* @param Request $request
* @param string $_locale
* @param string $category
* @param string $application
* @param CdnCache $cdn
* @return Response
*/
public function application(string $_locale, string $category, string $application, CdnCache $cdn): Response
public function application(Request $request, string $_locale, string $category, string $application, CdnCache $cdn): Response
{
if ($request->query->get('site_locale')) {
return $this->redirectToRoute('app_main_application_intl', ['_locale' => $request->query->get('site_locale'), 'category' => $category, 'application' => $application]);
}
$applicationObj = AppData::fromName($application);
if (!($applicationObj || startsWith($application, 'org'))) {
......@@ -92,14 +107,18 @@ class MainController extends AbstractController
/**
* @Route("/{category}/{application}/development", requirements={"_locale": "%app.locales%"}, defaults={"_locale": "en"})
* @Route("/{_locale}/{category}/{application}/development", name="app_main_application_dev_intl", requirements={"_locale": "%app.locales%"})
* @param Request $request
* @param string $_locale
* @param string $category
* @param string $application
* @param CdnCache $cdn
* @return Response
*/
public function applicationDevelopment(string $_locale, string $category, string $application, CdnCache $cdn): Response
public function applicationDevelopment(Request $request, string $_locale, string $category, string $application, CdnCache $cdn): Response
{
if ($request->query->get('site_locale')) {
return $this->redirectToRoute('app_main_application_dev_intl', ['_locale' => $request->query->get('site_locale'), 'category' => $category, 'application' => $application]);
}
$application = AppData::fromName($application);
return $this->render('main/applicationDevelopment.html.twig', [
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment