Welcome Guest, Not a member yet? Register   Sign In
HMVC: Base.php vs. Ci.php
#18

[eluser]Maarten Troonbeeckx[/eluser]
[quote author="wiredesignz" date="1309184883"]
CI_Controller is the regular one. I have not modified the core controller class. MX_Controller stands alone from the CI_Controller core when we use it in HMVC context.[/quote]

If you extend CI_Controller in the context of HMVC, you do end up with a modified version of the original CI_Controller (system/core/Controller.php), don't you?

In CI_Controller::__construct() when the Loader class is instantiated:
Code:
$this->load =& load_class('Loader', 'core');

$this->load is now an instance of MX_Loader (since MY_Loader extends MX_Loader), right?
At the end of the MX_Loader class code (/third_party/MX/Loader.php) there's this line of code:
Code:
(class_exists('CI', FALSE)) OR require dirname(__FILE__).'/Ci.php';

If you would have extended MX_Controller, CI would have already been there, since it was loaded in Base.php.
This is not the case, so CI is instantiated, self::$APP points to the current controller instance and a new MX_Loader is defined.
Code:
...
self::$APP = CI_Controller::get_instance();
        
global $LANG, $CFG;
        
/* re-assign language and config for modules */
if ( ! is_a($LANG, 'MX_Lang')) $LANG = new MX_Lang;
if ( ! is_a($CFG, 'MX_Config')) $CFG = new MX_Config;
        
/* assign the core loader */
self::$APP->load = new MX_Loader;
        
/* autoload module items */
self::$APP->load->_autoloader(array());
...
CI_Controller gets some extended functionality/variables, doesn't it?
That's what I mean with the "non regular" CI_Controller.

So why is this even needed?
If I want to use HMVC, why not just extend MX_Controller?
Maybe this extended functionality for CI_Controller is a fallback option when you forget to extend MX_Controller somewhere?


Messages In This Thread
HMVC: Base.php vs. Ci.php - by El Forum - 06-24-2011, 11:56 AM
HMVC: Base.php vs. Ci.php - by El Forum - 06-24-2011, 02:06 PM
HMVC: Base.php vs. Ci.php - by El Forum - 06-24-2011, 02:59 PM
HMVC: Base.php vs. Ci.php - by El Forum - 06-24-2011, 05:06 PM
HMVC: Base.php vs. Ci.php - by El Forum - 06-24-2011, 05:12 PM
HMVC: Base.php vs. Ci.php - by El Forum - 06-25-2011, 02:38 AM
HMVC: Base.php vs. Ci.php - by El Forum - 06-25-2011, 06:02 AM
HMVC: Base.php vs. Ci.php - by El Forum - 06-25-2011, 07:30 AM
HMVC: Base.php vs. Ci.php - by El Forum - 06-25-2011, 08:24 AM
HMVC: Base.php vs. Ci.php - by El Forum - 06-25-2011, 12:26 PM
HMVC: Base.php vs. Ci.php - by El Forum - 06-25-2011, 03:34 PM
HMVC: Base.php vs. Ci.php - by El Forum - 06-26-2011, 05:24 AM
HMVC: Base.php vs. Ci.php - by El Forum - 06-26-2011, 06:30 AM
HMVC: Base.php vs. Ci.php - by El Forum - 06-27-2011, 12:45 AM
HMVC: Base.php vs. Ci.php - by El Forum - 06-27-2011, 12:57 AM
HMVC: Base.php vs. Ci.php - by El Forum - 06-27-2011, 03:03 AM
HMVC: Base.php vs. Ci.php - by El Forum - 06-27-2011, 03:28 AM
HMVC: Base.php vs. Ci.php - by El Forum - 06-27-2011, 04:39 AM
HMVC: Base.php vs. Ci.php - by El Forum - 06-27-2011, 02:53 PM
HMVC: Base.php vs. Ci.php - by El Forum - 06-28-2011, 01:36 AM



Theme © iAndrew 2016 - Forum software by © MyBB