Im creating a plugin library, and in the constructor, im initiating a local static CI reference, using the get_instance() function. From the Library, I need to be able to hit a model, the issue im having, is if I try to execute a method from a model inside the constructor (Or execute a method in the constructor that executes a method from a model), it fails, however, if I execute the exact same thing from a method thats called from outside the library, it works just fine.
The controller I'm executing this from is Test, and the errors are:
Quote:Severity: Notice
Message: Undefined property: Test::$Plugins_model
Filename: libraries/Plugins_lib.php
Line Number: 33
Line 33 would is notated below..
Code:
PHP Code:
<?php
class Plugins_lib {
private static $CI;
public function __construct()
{
// Codeigniter instance
self::$CI =& get_instance();
// THIS FAILS...
$this->get_active_plugins();
}
// This gets executed externally (From controller)
public function active()
{
// THIS WORKS JUST FINE
return self::$CI->Plugins_model->get_active_plugins();
}
// This gets executed from the constructor
private function get_active_plugins()
{
// FAILS
return self::$CI->Plugins_model->get_active_plugins(); // Line 33
}
}
}
Any idea what the issue could be?