Welcome Guest, Not a member yet? Register   Sign In
Clarification about MY_Controller and relative inheritances
#10

(04-17-2017, 06:41 PM)dave friend Wrote:
(04-17-2017, 04:34 PM)marksman Wrote: @Dave friend, have you tried to var_dump in Backend_Controller's constructor? I'm afraid its not loaded. or try to instantiate it in your class Dashboard which is basically loaded by magic router.

PHP Code:
class Dashboard extends MY_Controller
{
 
   public function index()
 
   {
 
       // If this returns an error then your Backend_Controller is not loaded
 
       $oBackend = new Backend_Controller();
 
   }


You extend My_Controller to CI_Controller while Backend_Controller extends MY_Controller. I think you missed it my friend. No one extends or instantiate Backend_Controller so no chance to access it's instance, your Dashboard also extends to MY_Controller. In your structure MY_Controller stands as your base class neither Backend_Controller nor Frontend_Controller. That's why.

I think you're reading it wrong. Look at my code again.

  1. MY_Controller extends CI_Controller;
  2. Backend extends MY_Controller;
  3. Welcome extends Backend;
I substituted "Welcome" for the OP's "Dashboard" cause I was too lazy to create another class. Angel

The inheritance chain will instantiate Backend.

I know "Backend" was created because the object "river_m" is successfully used in "Welcome" to return data from the db.

In my example I did not define a Frontend class but if I did it would extend MY_Controller. Smile

Oh I see, My bad.

If that the case then would you think how CI include the file of backend/frontend controller without modifying config.php from MY_ convention to your own or by creating your own autoloader inside MY_Controller
God Bless CI Contributors Smile
Reply


Messages In This Thread
RE: Clarification about MY_Controller and relative inheritances - by marksman - 04-17-2017, 08:53 PM



Theme © iAndrew 2016 - Forum software by © MyBB