Symfony 5在某些请求中没有检测到正确的区域设置



我正在努力与Symfony如何设置区域设置。

这是我的annotations.yaml文件:

controllers_frontend:
resource: ../../src/Controller/Frontend
type: annotation
host:
'de-DE': example.de
'de-AT': example.at
'de-CH': example.ch
'fr-CH': example.ch
prefix:
de-DE: '' # don't prefix URLs for German
de-AT: ''
de-CH: '/de'
fr-CH: '/fr'

对于路由"some-route"in Controller A:

example.de/some-route -> locale = de-DE
example.at/some-route -> locale = de-AT
example.ch/de/some-route -> locale = de-CH
然后我有一个不同的控制器B这里我有以下问题:
example.de/swatch/checkout/confirm -> locale not detected, it goes back to the fall back locale
example.at/swatch/checkout/confirm -> locale not detected, it goes back to the fall back locale
example.ch/de/swatch/checkout/confirm -> locale = de-CH

这是该路由的代码

<?php
namespace AppControllerFrontend;
...
class OrderController extends AbstractController
{
/**
* @Route("/swatch/checkout/confirm", priority="10", name="swatch_checkout_confirm")
*/
public function checkout_confirm(Request $request, OrderHelper $orderHelper)
{
$country = $orderHelper->getCountry($request->getLocale());
return $this->render('frontend/order/checkout_confirm.html.twig',
array(
'country' => $country
)
);
}

自从我的区域设置在注解。yaml works for"some-route",我相信它是正确的。

我找到了解决办法。当我删除"优先级"时;从路由中,正确地检测到区域设置。不确定这是Symfony中的错误还是我的区域设置错误。

最新更新