I created a CRUD model for the database table in the form of Active Record. If the validation and saving of some fields in the models execute additional operations. The class was quite large. To make the architecture of the code more understandable, I have divided some of the fields into groups and made their logic in a separate submodel, but the field left in the main model. I was going to start the class validate_all(), and call submodel1->validate () submodel2->validate().
But! To save validation errors in the main model, and overwrite the fields for the main model subclass requires access to the object of the main model. But I can't pass to the function the value of $this. For example, I call a function validate_all() main class, and in it I need to call the function validate_meta child class. And this method needs to have access to the instance of the parent class. How to organize it?
I must say that I would not like to split up a table for a subdatasheet. Must exist a pattern that will allow the subclass to access the class. While comes to mind only to send a reference to an object from outside:
$item = new Item();
$item->obj = $item;
It is inconvenient and not at all sure this will work