Passing an object between two controllers
I have two controllers , and I have one object.
I want to pass that object between my two controllers in CodeIgniter. There is a registry or something like that?? Example - I am using ipbwi (for invision power board 3.1 integra开发者_StackOverflowtion ) , on my main controller I am doing this - private $ipbwi;function Main()
{
parent::Controller();
$this->site_url = $this->config->item('base_url');
$this->ipb_dir = $this->config->item('ipb_dir');
include('ipbwi/ipbwi.inc.php');
$this->ipbwi = clone $ipbwi;
}
I want to access $ipbwi from my admin controller and don`t clone this object again.
By passing object , I mean that I can create object add Controller A and access it from Controller B.FIXED
I used the session class to check if the user is connected or not and if he is admin.An MVC controller's purpose is to handle input from the UI and delegate it to an appropriate class in the model. You should not have the need to pass an object between controllers.
What exactly do you mean by passing an object between two controllers?
One approach is to create a base controller, and in the base constructor create that object.
精彩评论