Welcome Guest, Not a member yet? Register   Sign In
Accesing Controller Data from module
#1

[eluser]Uto[/eluser]
Is it possible to access to properties of the calling controller from a module other than passing it as parameters?

I mean something like:

Code:
$this->parent->propertyname

I have a module that was able to load all data needed from constructor itself, no needing any parameters, and it's widely used in the application. But now, under some circunstances, that happen a 0.5% of the times it's used, it may need to get a property from the "parent" controller, and changing it all over the code is quite risky.
#2

[eluser]pistolPete[/eluser]
What do you mean by "parent" controller, do you mean class inheritance?
Code:
Parent_controller extends Controller {
   protected $data;
}

Some_controller extends Parent_controller{
   function test()
   {
      $this->data;
   }
}
#3

[eluser]Uto[/eluser]
[quote author="pistolPete" date="1240584759"]What do you mean by "parent" controller, do you mean class inheritance?
Code:
Parent_controller extends Controller {
   protected $data;
}

Some_controller extends Parent_controller{
   function test()
   {
      $this->data;
   }
}
[/quote]

Well, I explained it badly. I mean the "calling" controller, like:

In the controller:
Code:
$this->someproperty = 10;
$this->load->module("mymodule");

In the module:
Code:
$x = $this->callingcontroller->someproperty;




Theme © iAndrew 2016 - Forum software by © MyBB