开发者

Filter before routing, and sfStopExceptions

I would like to create a filter that runs before the routing system does and am wondering if this is possible.

Specifically, I would like to parse and redirect URLs myself in certain situations using a filter. The urls that needed to be parsed using my filter will otherwise fall through all the rules in my routing.yml.

Currently what I'm doing is running the filter first in filters.yml, but when I need to redirect in my filter a variety of bad things happen:

  1. sfStopExceptions and sfError404Exceptions are thrown anyway and clutter up my logs (see this bug: http://trac.symfony-project.org/ticket/4741)
  2. I get a whole bunch of lines like this in my log:

[Mon Mar 07 14:24:48 2011] [error] [client 67.184.53.79] FastCGI: server "/var/local/fcgi/php-cgi-wrapper.fcgi" stderr: Empty module and/ or action after parsing the URL "/files/beezee50.png" (/)., referer: http:开发者_JAVA技巧//bee-zee-body-shop.blahblah.mobi/bee-zee-body-shop

[Mon Mar 07 14:24:53 2011] [error] [client 67.184.53.79] FastCGI: server "/var/local/fcgi/php-cgi-wrapper.fcgi" stderr: Action "beezeebodyshop/index" does not exist.

If I was able to redirect successfully before the routing was done, none of this should happen.


I would subclass sfPatternRouting (which is the most common sfRouting instance configured in the application's factories.yml file), to handle those special cases you need to address, and do the regular stuff otherwise.
You can set up your new routing class like this in the factories.yml:

all:
  routing:
    class: yourAdvancedRouting
    param:
      generate_shortest_url:            true
      extra_parameters_as_query_string: true
      any_other_param_you_need:         value
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜