Open ghost opened 8 years ago
solve?
How about the autoform
?
This is ready. Right after I finish refactoring controllers I'll push all the commits (there are a lot of them). Autoform is still a high priority.
I'm thinking over this one as well. Should we allocate controllers? Isn't it too much magic? Especially when it comes to these single allocation rules. Can we come up with another solution for sharing state between actions of different controllers?
Glad to see the goal is still activate!
Intro
There is a controller with its special action:
The controller above is embedded by a number of other controllers.
Those controllers are embedded by our main controller.
Problem
The problem is the
GrandParent
controller will be allocated twice, meaningc.Parent1.GrandParent != c.Parent2.GrandParent
. The output of theGrandParent
'sBefore
will be:As a result, we cannot share a context between controllers of different levels of embedding.
Use-case
This is the problem I've faced trying to implement #39. There is
controllers/errors
controller that is responsible for rendering error pages. We embed it in our main controller and mount its actions to* /errors
:Now if we want to pass some value to the actions of that
Errors
controller it doesn't work:Because,
Context
ofControllers
andContext
ofErrors
are different instances. But they must be pointers to the same object.Expectations
A single allocation per object per request. Special (
Before
andAfter
) actions must be called just once:Parents
must have priority over theirChildren
.