I am attempting to write a lazy loader for models + libraries in CI 3.0.4
I am trying to get the following as described in:
Model/library lazy load in CodeIgniter
This code seems to be for CI version 2 and when I tried to apply it to CI version 3.0.4 I get the following errors.
Message: Indirect modification of overloaded property Items::$benchmark has no effect
Line Number: 75
Fatal error: Cannot assign by reference to overloaded object in /Applications/MAMP/htdocs/phppos/PHP-Point-Of-Sale/system/core/Controller.php on line 75
Here is what I did:
Create file application/core/MY_Controller.php
Create the following code:
//Lazy load based on http://stackoverflow.com/questions/17579449/model-library-lazy-load-in-codeigniter
if (isset($this->$name) && $this->$name instanceof CI_Model)
Once I can get this to work without errors; I will add my custom logic to load the right model or library.
I want to do this WITHOUT modifying core.