Symfony 1.4的路由问题

时间:2013-05-20 15:50:56

标签: symfony1 symfony-1.4 yaml

我必须使用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错误。

我知道为什么会出现这种路由问题?

2 个答案:

答案 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 }

并清除缓存。