symfony sfDoctrineRouteCollection routing throws 404 error "Empty module and/or action after parsing the URL..."
I have the following routing configuration:
entry:
class: sfDoctrineRouteCollection
options:
model: ProjectEntry
module: entry
prefix_path: /entry
column: slug
with_show: false
model_methods:
{ object: getEntryBySlug }
requirements:
slug: \w+
which, among others, gives me the following output with the symfony app:routes :
entry_edit GET /entry/:slug/edit.:sf_format
at lib/model/doctrine/ProjectEntryTable.class.php I have the following method:
public static function getEntryBySlug($parameters)
{
return Doctrine_Core::getTable('ProjectEntry')->findOneBySlug($parameters['slug']);
}
However, when I enter an URL such as:
frontend_dev.php/entry/my-slug/edit
I get the following error:
404 | Not Found | sfError404Exception
Empty module and/or action after parsing the URL "/entry/my-slug/edit" (/).
(assume that my-slug is a valid slug for some record at开发者_StackOverflow社区 ProjectEntry table)
I haven't found the cause of this error, what may I be doing wrong?
As far as I can tell, the problem is at the routing configuration (but where?!), because even if I try to debug something at my executeEdit action, I notice that I don't even get there. (If it's needed, I can post more code/output here...)
Any ideas deeply appreciated...
Ok, got it!
I just had to remove the requirement for the slug and that was it.
The thing is that sfDoctrineRouteCollection (and maybe other sfObjectRouteCollections? anyone knows?) generates its routes, like the edit one, as:
prefix/column/edit
so if column has a \w+ requirement, it is basically saying that anything after the prefix is part of the column, including the '/edit' part. Removing the requirement loads the default one ([^ / \ \ .]+), which as far as I understand of regexes says that the next '/' is the limit...
sorry for such a newbie question, but it is now solved...
精彩评论