我必须使用Symphony 1.4升级之前由其他人开发的应用程序。
在我的action.class.php中有两个不同的功能:
public function executeCreateTask(sfWebRequest $request) {...}
public function executeCreateEvent(sfWebRequest $request) {...}
在我的routing.yml里面我有两条路线:
evaluation_task_create:
url: /evaluation/:id/task/create
class: sfDoctrineRoute
options: { model: Evaluation, type: object }
param: { module: evaluation, action: createTask, sf_format: html }
requirements: { sf_method: post }
和
evaluation_event_create:
url: /evaluation/:evaluation_id/event/create
class: sfDoctrineRoute
options: { model: CustomEvent, type: object }
param: { module: evaluation, action: createEvent, sf_format: html }
requirements: { sf_method: post }
网址 http://www.mysite/evaluation/21/task/create完美运行(创建新任务)
网址 http://www.mysite/evaluation/21/event/create返回404错误。
我知道为什么会出现这种路由问题?
答案 0 :(得分:2)
您需要能够进一步调试,因为您没有得到sfError404Exception。您是否在ApplicationConfiguration中将debug
设置为true?您可以在dev
环境的webdispatcher中执行此操作。
$configuration = ProjectConfiguration::getApplicationConfiguration(
'backend',
'dev',
true
);
在您的应用中settings.yml
:
dev:
error_reporting: <?php echo (E_ALL | E_STRICT)."\n" ?>
web_debug: true
在您的应用程序中factories.yml
确保已设置
dev:
logger:
param:
loggers:
sf_web_debug:
param:
xdebug_logging: true
答案 1 :(得分:0)
在createEvent
模块的evaluation
操作中,您可能有类似
$this->evalution = $this->getRoute()->getObject();
要从路径中获取正确的对象,您需要使用:id
变量作为对象的ID,并指定正确的模型Evaluation
而不是CustomEvent
。因此,请尝试将evaluation_event_create
路线更改为:
evaluation_event_create:
url: /evaluation/:id/event/create
class: sfDoctrineRoute
options: { model: Evaluation, type: object }
param: { module: evaluation, action: createEvent, sf_format: html }
requirements: { sf_method: post }
并清除缓存。