PDA

View Full Version : Creating a controller to be programmatically called not triggered by an event



inoabrian
1 Jul 2014, 6:51 AM
How would I create a controller that will be called from another controller.
Would I just exclude the init function? ~o)

arthurakay
1 Jul 2014, 7:17 AM
Let's back up and explain what you're trying to do here.

Controllers are essentially classes that execute logic *in response to events*. That's an over-generalization, but for the most part my statement holds true.

When you say "a controller that will be called from another controller", do you simply want to call a function defined in another controller? Because if so, you might just put that function in a utility class where it can be called from anywhere, at any time.

Controllers in MVC aren't really designed to call each other because (as I said) they're designed to respond to events. You could manually fire events in one controller which would be received by the second controller... but that just seems overly complicated.

If my suggestion hasn't helped, please clarify what you're trying to do specifically.