Posts: 60
Threads: 14
Joined: Jul 2017
Reputation:
0
07-10-2018, 06:42 PM
(This post was last modified: 07-10-2018, 07:45 PM by scalla.)
good day @kilishan
based on the refactoring of the controller class about 21 hours ago, removing the use of constructor from it, how is the (request, response) object going to be used in other controllers?? prior to the refactoring, it was straight forward.
Posts: 60
Threads: 14
Joined: Jul 2017
Reputation:
0
oh i get, but why the revert from it previous way?? is it due to the redirect issue!!
Posts: 911
Threads: 40
Joined: Oct 2014
Reputation:
70
Honestly, not sure it changes the redirect issue. Wasn't trying to fix that since Filters does most of what people are trying to redirect in constructors for...
Mainly it was to clean things up a bit, and make it a little simpler for developers. It sounds like it's causing you pain, though. What are you running into?
Posts: 911
Threads: 40
Joined: Oct 2014
Reputation:
70
Hm. Used to work, but it's been a while since I've been in that code. Please file an issue over at Github or else this will get lost in the shuffle.
Posts: 158
Threads: 9
Joined: Dec 2015
Reputation:
7
07-11-2018, 09:42 AM
(This post was last modified: 07-11-2018, 09:43 AM by enlivenapp.)
Sorry for the probably dumb question... between this and the other thread I'm still somewhat confused.
So do we use `intController()` now instead of `__contsruct()` when we need to automatically set things up controller-wide? (like setting class members, etc?)
Additionally, is this change only in controllers, or will it move out to models, libraries, etc?
Posts: 911
Threads: 40
Joined: Oct 2014
Reputation:
70
Correct - you do not need to even think about the initController method. That's called by CodeIgniter when the Controller is instantiated, and just frees you from having to worry about constructor arguments whenever you need to do something in your controller's constructor.
And the "redirect issue" in the controller constructor isn't able to be fixed as you cannot return another object from a class constructor. You can always use filters (once investigated and fixed) or the _remap method in the controller.