Welcome Guest, Not a member yet? Register   Sign In
How to use functionality of another controller (render its view inside mine)?
#6

(This post was last modified: 10-14-2015, 07:45 AM by mwhitney.)

(10-14-2015, 12:33 AM)Kulavert Wrote:
(10-13-2015, 01:09 PM)mwhitney Wrote: Instead of calling Tank-Auth's auth controller, use it as an example and add the necessary functionality into your base controller (usually MY_Controller). You really just need to setup your own login view, retrieve the values from the view, validate them, then pass them to the tank_auth->login() method.

Quote:lazyfox
I suggest, you define all variables needed in your controller and call it to your views. Do not initialize your controller in your views.

Doing so means:
1) Defining all variables and logic in my controller = duplicating code;
2) Moving that code to my controller = breaking another controller;
3) Moving necessary code to library/helper = breaking the concepts of MVC;
Besides, target controller may be a third-party component (as it is in my example), so changing it and those things above - are very bad practices, I believe!

If you don't want to move the code from the Auth controller, then you need your controller(s) to extend the Auth controller and make sure the Auth controller is auto-loaded.

However, it's possible that, at some point, you'll have to pull some of the original code from the Auth controller into a method within your own base controller just to be able to setup the data for a view without calling the original controller's method(s). Part of this is simply a design issue with the original component, and is why my original instinct was to treat the Auth controller as an example and the Tank_auth library as the important 3rd party component.
Reply


Messages In This Thread
RE: How to use functionality of another controller (render its view inside mine)? - by mwhitney - 10-14-2015, 07:45 AM



Theme © iAndrew 2016 - Forum software by © MyBB