Symfony sf_culture = 1 error

◇◆丶佛笑我妖孽 提交于 2019-12-13 02:25:48

问题


I'm getting a lot of errors because of sf_culture = 1 on the server.

{sfConfigurationException} Unable to find a matching route to generate url 
for params "array (  'action' => 'legend',  'module' => 'housing',  'sf_culture' =>'1',)"

Locally this matches the default route:

Match route "default" (/:sf_culture/:module/:action/*) for /de_DE/housing/legend with 
parameters array (  'module' => 'housing',  'action' => 'legend',  'sf_format' => 'html',  
'sf_culture' => 'de_DE',)

wich looks like this

default:
  url:   /:sf_culture/:module/:action/*
  param: { sf_format: html }
  requirements:
    sf_culture: (?:<?php echo $cultures ?>)

Why is it even possible that :sf_culture or $sf_user->getCulture() is returning '1', also I have seen 'de?keepthis=true' in the logs which is even more strange.

What can I do about this error?

EDIT: I can't be the only one with this error? I mean just look at these logs (~ 1 Minute)

May 10 09:50:23 symfony [err] {sfConfigurationException} Unable to find a matching route to generate url for params "array (  'action' => 'legend',  'module' => 'housing',  'sf_culture' => 'en“',)".
May 10 09:50:34 symfony [err] {sfConfigurationException} Unable to find a matching route to generate url for params "array (  'action' => 'legend',  'module' => 'housing',  'sf_culture' => 'mvcleltja',)".
May 10 09:50:45 symfony [err] {sfConfigurationException} Unable to find a matching route to generate url for params "array (  'action' => 'legend',  'module' => 'housing',  'sf_culture' => '√ en',)".
May 10 09:51:26 symfony [err] {sfConfigurationException} Unable to find a matching route to generate url for params "array (  'action' => 'legend',  'module' => 'housing',  'sf_culture' => '1',)".
May 10 09:51:42 symfony [err] {sfConfigurationException} Unable to find a matching route to generate url for params "array (  'action' => 'legend',  'module' => 'housing',  'sf_culture' => 'whwgopshwhyrydi',)".

回答1:


You can restrict the allowed cultures in your URLs via the routing.yml (apps/appname/config/routing.yml) like so:

localized_homepage:
  url: /:sf_culture/
  param: { module: yourmodule, action: youraction }
  requirements:
    sf_culture: (?:fr|en)


来源:https://stackoverflow.com/questions/10330962/symfony-sf-culture-1-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!