I'm using the following scenario, but this doesn't necessarily pertain only to CodeIgniter.
HMVC: https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc
Internationalization (i18n): https://github.com/waqleh/codeigniter-language-in-url-internationalization
Both HMVC & i18n work by extending CI_Config
(and related CI_
classes).
To get i18n working alongside HMVC, I first have to require the appropriate HMVC file and then further extend that class.
So for example, CI_Config
is extended by HMVC MX_Config
and then further required & extended by i18n MY_Config
.
But now i18n only works if HMVC is already in place.
What if HMVC is absent (no MX_Config
and related)?
I want i18n to work both with/without HMVC.
Is there a way to conditionally require & extend one class or another? Or rather, extend CI_Config
(and related) twice without collision? Or is there another way to accomplish what I want?
HMVC MX_Config
partial:
/**
* HMVC
*/
class MX_Config extends CI_Config
{
i18n MY_Config
partial:
/* load HMVC's MX_Config class */
require APPPATH . "third_party/MX/Config.php";
/**
* Language
*/
class MY_Config extends MX_Config
{