I love using objects, it is just my way of working.
In one of my phtml scripts it could look like:
1 | echo $this->register->node->user->name; |
And it refers to the users name of the person who made an entry in my registry. Now this might not be the typical case, as this is limited to only one node per register. You would instead set up node to be an array and loop through it with a foreach for example.
1 2 3 | foreach($this->register->node as $node){ echo $node->id . ", " . $node->user->name . "<br>"; } |
Register is setup in the controller, and this is how I access the deep nested information I need. Rather then using arrays that are deep and not very understandable, or by giving an object 100 variables, such as $register->user_name, I prefer using an object for that which contains all information nesesary.
It should be added that this could be an potential improvement if you are working with a designer that knows just enough php to use your code and slightly modify it to make some tiny changes. For example knows that within these something is displayed, and can then find out by looking at $node->user->name to knos what data is shown.