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:
- sfStopExceptions and sfError404Exceptions are thrown anyway and
clutter up my logs (see this bug: http://trac.symfony-project.org/ticket/4741) - 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://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: