On Sun, Jan 2, 2011 at 9:08 AM, Svetoslav Shterev <[email protected]> wrote:

> On Sat, 2011-01-01 at 23:36 -0800, benze wrote:
> > Hi,
> >
> > I'm trying to figure out the best way to reuse an action, and am
> > having difficulty figuring that out.  Specifically because my action
> > seems to be tied to the response.
> >
> > For instance, I have a delete action that I want to call from within
> > several different web pages, however, depending on which page is
> > calling the delete action, I want to redirect the user to a different
> > page once complete.  I'm not quite sure if/how to do that.
> >
>
> You have three possibilities of obtaining the data needed to decide
> where to redirect. One is the URL(different routes into the action), the
> second is the get/post data(redirect_to token), and the third is the
> session/db. Here's an example of n1 working:
>
> // In the action
>
> $route_name = $this->getContext()->getRouting()->getCurrentRouteName();
> switch($route_name) {
>  case 'route_1':
>    $this->redirect('to_1');
> ...
> }
>
>
> I don't know what you meant by the java stuff. Workflow is controlled by
> the filters and action already. You could have a redirection filter
> working after the execution filter that sets what to redirect to.
>
>
Thanks for the tip.  That's kind of what I was looking for.  Ideally, the
great thing about Struts2 is that you can also put the action to take based
on the result in a config file, which completely separates the workflow from
the action.  In symfony, the way I see it, the action needs to know
something about the workflow (ie: if came from route A, redirect, if route
B, display template, if route C, chain another action, etc...).  Which ties
the action to the workflow.  What I would have loved to see is a config file
similar to the routing yml which would inspect the result from the action,
and determine what the next step would be.  If we managed to contain
everything in one file, it would be awesome.

For ex what I would love to see would be something along these lines:
url: /profile/delete
param: { module: profile, action: delete }
result: { success: redirect=>/profile/index }

url: /profile/replace
param: { module: profile, action: delete }
result: { success: redirect=>/profile/newProfile }

etc...


That way, you don't need to code any knowledge of where the action was
called from, or where it needs to go within the action.  The action could
take care of just it's core business, and leave the workflow to external
config files.

But, given the way symfony stands today, I'll use your suggestion and code
workflow within the action based on the routing.

Thanks,

Eric

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" 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-users?hl=en

Reply via email to