0
votes

I am having a problen with using an object with a url_for method, I thought the idea was any require parapeters were found automatically?

The "/publish/:id/:token" route has some missing mandatory parameters (:id, :token).

routing.yml

post_publish:
  url:     /publish/:id/:token
  options:
    model: HookupPost
    type:  object
    method_for_criteria: doSelectOneInactive
  param:   { module: post, action: show }
  requirements:
    id: \d+
    token: \w+
    sf_method: [GET]

newSuccess.php

<?php echo public_path(url_for("@post_publish", $post), true); ?>

Where $post is passed by the action and contains the recently created post!

Does anyone know why this error is occurring? Have I misunderstood something?

Thanks,

2

2 Answers

2
votes

You're missing the sfDoctrineRoute declaration:

post_publish:
  url:     /publish/:id/:token
  class:   sfDoctrineRoute
  options:
    model: HookupPost
    type:  object
    method_for_criteria: doSelectOneInactive
  param:   { module: post, action: show }
  requirements:
    id: \d+
    token: \w+
    sf_method: [GET]

And then you can do:

<?php echo public_path(url_for("post_publish", $post), true); ?>

Reference: http://www.symfony-project.org/jobeet/1_4/Doctrine/en/05

0
votes

Try:

<?php echo public_path(url_for("post_publish", 
        array( 'id' => $post->id, 'token' => $post->token )), true); ?>

Or something similar, depending on your Post class.