Welcome Guest, Not a member yet? Register   Sign In
Modular Extensions - HMVC version 5.3

[eluser]lexusgs430[/eluser]
Question for ya regarding extending the main MX_Controller file.

Im reusing the same exact function in a good number of my modules. Id like to be able to make this function globally accessible from any module, as I use it to set and add variables within the module classes. (as I am using modules as objects in most instances) -- I cant figure out how I can do it, I tried adding the function to the main MX_Controller but it doesen't seem to inherit properly. Can anyone tell me what I am doing wrong here?

Code:
public function __call($name, $arguments) {
        if (substr($name,0,4) == 'set_') {
            $property = substr($name,4);
            $this->$property = $arguments[0];
        } else if (substr($name,0,4) == 'add_') {
            $property = substr($name,4);
            array_push($this->$property, $arguments[0]);
        }
        return $this;
    }

And just to clarify, I want to be able to set the variables of modules after they have been created as objects, using that method. For example:

Code:
$this->load->module('example');
$e = new Example();
$e->set_outputtext('I am the example module');
echo $e->outputtext;

And I dont want to have to include the previous function within the example module itself.

Any ideas as how to do it?

[eluser]shanemesser[/eluser]
could you just use;

Code:
$this->example->e->set_outputtext('I am the example module');
echo $this->example->e->outputtext;

where example is the module, e is the class

[eluser]lexusgs430[/eluser]
$this->load->module('example');

is the module and the class. I am loading the module just to have access to the class without creating an instance. After it is loaded I create an instance of the object i.e. - $e = new Example();

[eluser]shanemesser[/eluser]
right, but:
Code:
$this->load->module(‘example’)
  $this->load->module(‘example/example’)


... mean the same thing. so in this case, isn't loading the module also forcing "example" to load (and instantiate) as $this->example->example already?

[eluser]lexusgs430[/eluser]
Im confused as to what you are getting at.

Yes, $this->example->set_outputtext('this test');

would be the same as me going

$this->load->module('example');
$e = new Example();
$e->set_outputtext('this test');

I just prefer to use the second syntax because I am in many cases using modules as objects and calling it the second way makes more sense to my brain.

But that doesen't really relate to my question. Im not trying to put that __call magic method in the example module, I am trying to put it somewhere (like the Mx_Controller class file), where all of the modules that extend Mx_Controller can use that function. So that if I am using
$e = new Example();
I can use that __call function to dynamically set the properties of the $e object, without redeclaring the __call magic method in a bunch of different modules in which I am using it.

[eluser]shanemesser[/eluser]
Is there a way to accomplish this?
Code:
$var = get_instance()->var;
$var = 1;
modules::run("M1/C/F", &$var); // $var is 1 going in and coming out, even in $var is changed inside F
modules::run("M2/C/F", &$var); // $var is still 1 going in and coming out, even in $var is changed inside F
// $var is still 1
when I do this, and I make changes to $var inside the module (M1), those changes are not being reflected in $var and it seems as though it's performing a copy by value vs. reference. Thus, inside M2, $var is the same as it was

[eluser]Tadej[/eluser]
Hey guys.

Just wondering - what is the current minimum PHP version for Modular Extensions?
Probably not <5, right? :coolsmile:

Regards,
Tadej

[eluser]lexusgs430[/eluser]
Yes you will need at least php 5 I dont know specifically what version, I would imagine 5.3 though since the he included 5.3 in the name of it Smile

[quote author="Tadej" date="1294780480"]Hey guys.

Just wondering - what is the current minimum PHP version for Modular Extensions?
Probably not <5, right? :coolsmile:

Regards,
Tadej[/quote]

[eluser]Tadej[/eluser]
[quote author="lexusgs430" date="1295059604"]Yes you will need at least php 5 I dont know specifically what version, I would imagine 5.3 though since the he included 5.3 in the name of it Smile

[quote author="Tadej" date="1294780480"]Hey guys.

Just wondering - what is the current minimum PHP version for Modular Extensions?
Probably not <5, right? :coolsmile:

Regards,
Tadej[/quote][/quote]

Yeah, I was wondering if the 5.3 had any connection ... ;-P

Thanks,
Tadej

[eluser]Abu eldahab[/eluser]
hello,

I have problems with HMVC after upgrade from 5.3.4 to 5.3.5 all files replaced expect Base.php & loader

when replace Base.php I'm getting this errror

Code:
Fatal error: Class 'CI_Controller' not found in /third_party/MX/Base.php on line 41

my CI_VERSION is 2.0


also getting errors with loader.php

when using version 5.3.4 working fine




Theme © iAndrew 2016 - Forum software by © MyBB