Overriding core classes |
I tryed to override the core controller following this page :
https://www.codeigniter.com/userguide3/g...asses.html I added a new class in /application/core/ PHP Code: <?php I checked, line 374 of /system/core/CodeIgniter.php is called properly : PHP Code: require_once APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php'; But constructor is not called. What am I doing wrong ?
Huh... go figure. I've created MY_Controller classes on many occasions without any problem.
Line #374 from Codeigniter.php only makes the class code available, it does not instantiate it. PHP Code: require_once APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php'; The controller is instantiated on line #518 PHP Code: $CI = new $class(); There's a whole bunch of error checking going on in between most of which results in a 404 if all the pieces cannot be found. You don't mention getting any errors. Did you? (10-17-2018, 02:37 PM)dave friend Wrote: You don't mention getting any errors. Did you? That's very kind to you to answer to me. I no longer have any problems or errors : everything is fine now as I explained previously: Quote:I solved the problem myself : I didn't extend my controllers with MY_controller, it was still CI_controller. That was my mistake.
Just a note here you do not have to name the class MY_Controller, you can name the class whatever you want.
It just needs to be saved with the MY_Controller.php filename. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(10-18-2018, 12:26 AM)imabot Wrote: That's very kind to you to answer to me. I no longer have any problems or errors : everything is fine now as I explained previously: And my mistake was not understanding your explanation of the problem. I'm glad to hear it was a simple problem. Sometimes those kinds of "bugs" are the hardest to find. (10-18-2018, 05:30 AM)dave friend Wrote:(10-18-2018, 12:26 AM)imabot Wrote: That's very kind to you to answer to me. I no longer have any problems or errors : everything is fine now as I explained previously: Maybe you could help me with the next one : https://forum.codeigniter.com/thread-71960.html ! |
Welcome Guest, Not a member yet? Register Sign In |