I am against reposting an old topic, but since I know have a better understanding of it, however I lack the best answer
This is the old topic: http://www.yiiframew…ic-redirection/
Dynamic Redirection I mean to not know from before to where the redirect of an action will take you. The route is defined with a parameter.
Someone might argue that you need to start from somewhere so, a fully dynamic and flexible system where all the redirections are dynamic does not seem so possible. I agree with that
Let’s take an example. I have an controller named Finder
The Finder uses different ways but always ends up with the same thing: to retrieve the id attribute of an ActiveRecord (suppose the corresponding table has a column named "id")
As you imagine there are multiple other controllers who take advantage of the Finder.
The Finder must indeed have a dynamic redirection. At the end it must return, redirect, to the controller who requested to know "id" of this table.
The way I modelled it was to apply a parameter named "params" in almost all Actions.
So "params" is an array. If you have a sequence of actions Action0 -> Action1 -> Action2 every action can append variables as we go along.
The dynamic redirection is required only at the end of this process. Action0 should have received a parameter and this parameters perpetuates until Action2 and then Action2 redirects (dynamically) to the action of the controller who called the Finder (in one word, the caller)
Note I didn’t use filters, the embedded feature of Yii. This implementation might have helped but the question, as far as the modelling is concerned, remains!
Also Note that I didn’t use any session variables. Maybe I should but this would require a very careful design since session variables could conflict. A simple case is if the user opens the same page twice…
My intuition tells me that unfortunately my solution is not viable. Do you have any other ideas for modelling or any other ways to deal with the matter more elegantly?
Unless I didn’t make myself clear with all the above let me add this: Imagine that an action requests an information from a controller (for example the Finder) so we have a new branch in our flow where a sequence of actions takes place until we get that information back. So maybe the Finder itself request an information from ANOTHER controller so we have a NEW branch!!!
Any ideas are welcome! It is much easier at this point to refactor the source code.
Thank you a lot!