From a code igniter function I am loading a library with arguments and it performs a bunch of things and initiliazes the library instance.
What is the right way to pass this instance to another function?
EDIT:
public function init()
{
//...
$dataArr = array('directory' => $myDir, 'run' => TRUE);
$this->load->library('lib_mylib', $dataArr);
// here I want to pass the lib_mylib instance to final();
// lib my lib has variables that gets set when loaded, I don't want to reloaded it again in the next function because it performs some operations that should only happen once. How can I get a handle of that initiliazed library inside final?
}
public function final($inputLibMyLib)
{
}
Assuming this code is in your Controller, just load the library in the Controller’s constructor…
This constructor is called every time a function is requested.
CLARIFICATION
Doing this in the constructor is the best place because it guarantees that it is loaded before any following functions are.
However…
If you are calling functions sequentially the loaded library will hold over…
example