Well, you can do something more 'cleaner'. No idea if it is a good
thing to add a redirect in the component, but if you don't have the
choice ...
[...]
$this->getController()->redirect(url_for('module/action'), true);
return sfView::NONE;
[...]
Thomas
On Fri, Apr 11, 2008 at 9:13 AM, Christian Schaefer <[EMAIL PROTECTED]> wrote:
>
> hi all,
>
> I recently toyed around with a little plugin of mine where I thought
> it would be appropriate to have components that provide functionality
> like commenting. this component I thought should also handle posted
> comments and save them.
>
> the first way would have been to have a dedicated route to a dedicated
> action saving the comment and redirecting to the url it was called
> from. this would mean you'd have to rely on the referrer or that you
> have to pass the url to your saving action. but you would loose url
> hash parameters like #someinterestingpartofthesite.
>
> the other way I have chosen is to trigger the saving within the
> component. unfortunately you have no redirect() method on your
> component. So I want to share with you my solution for this:
>
>
> /**
> * Post/Redirect/Get (PRG) [EMAIL PROTECTED]
> http://en.wikipedia.org/wiki/Post/Redirect/Get}
> * Fetch the current action, clear the request parameters and
> set the request method to get.
> * This will reset the current (and already processed) request
> to a vanilla GET request, thus
> * no longer triggering this save method.
> * Then use the current action object to redirect to itself. All
> POST data will have been
> * removed from the request.
> */
> $current_action = sfContext::getInstance()->getActionStack()-
> >getLastEntry()->getActionInstance();
> $this->getRequest()->getParameterHolder()->clear();
> $this->getRequest()->setMethod(sfRequest::GET);
> $current_action->redirect($current_action->getModuleName().'/'.
> $current_action->getActionName());
>
>
> any thought on this? any reasons to shout 'Oh nooo, don't do THAT!'?
>
> cheers
> /christian
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en
-~----------~----~----~----~------~----~------~--~---