Hi All,
I just have a question regarding injecting dependencies and lazy loading.
The way I have developed my objects (model classes) is to pass in an array
of data to the constructor, this mainly hanldes the setting of scalar
properties (strings, int's etc) on the object,
when I wish to load a property that is an object my aim is to lazy load it
on demand.
What is the best way to accomplish this?
I am going to do this via setter injection in the model, so my first
thought is to use a DiC,
accessible via model classes, is this a common approach?
Or I was also thinking about creating a lazy_load method that would be
utilized by model getter methods:
Something like so:
....
public function getProp()
return lazy_load($this->prop, $className, $args);
}
...
Then inside the lazy load function, I could harness the DiC?
Any comments or improvements on this approach?
Many Thanks
Daniel