Routing issue with Symfony 1.4

I have to upgrade an application previously developed by other guys with Symphony 1.4.

Inside my action.class.php there are two different functions:

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

and inside my routing.yml I have 2 routes:

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 }

and

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 } 

The url http://www.mysite/evaluation/21/task/create works perfectly (Creates a new task)

The url http://www.mysite/evaluation/21/event/create returns an 404 error.

Any idea why I have this routing issue?

Upvotes: 0

Views: 3275

Answers (2)

Visavì
Visavì

Reputation: 2333

In the createEvent action of your evaluation module, you have probably something like

 $this->evalution = $this->getRoute()->getObject();

To get the right object from the route, you need to use :id variable for the id of the object and specify the right model Evaluation and not CustomEvent. So try to change evaluation_event_create route to:

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 }

and clear your cache.

Upvotes: 0

meijuh
meijuh

Reputation: 1077

You need to be able to debug further, since you are not getting an sfError404Exception. Have you set debug to true in your ApplicationConfiguration? You can do this in your webdispatcher for your dev environment.

$configuration = ProjectConfiguration::getApplicationConfiguration(
    'backend',
    'dev',
    true
);

And in your application's settings.yml:

dev:
  error_reporting: <?php echo (E_ALL | E_STRICT)."\n" ?>
  web_debug: true

And in your application's factories.yml make sure you have set

dev:
  logger:
    param:
      loggers:
        sf_web_debug:
          param:
            xdebug_logging: true

Upvotes: 2

Related Questions