0

我必须升级以前由其他人使用 Symphony 1.4 开发的应用程序。

在我的 action.class.php 中有两个不同的函数:

public function executeCreateTask(sfWebRequest $request) {...}
public function executeCreateEvent(sfWebRequest $request) {...}

在我的 routing.yml 中,我有 2 条路线:

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完美运行(创建一个新任务)

url http://www.mysite/evaluation/21/event/create返回 404 错误。

知道为什么我有这个路由问题吗?

4

2 回答 2

2

您需要能够进一步调试,因为您没有收到 sfError404Exception。您是否debug在 ApplicationConfiguration 中设置为 true?您可以在 webdispatcher 中为您的dev环境执行此操作。

$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
于 2013-05-21T07:14:54.283 回答
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 }

并清除缓存。

于 2013-05-21T09:03:41.653 回答