Hi!
The situation I'm now is is that I want to hook some extra behavior to rows, when a field changes. So for a field "name", I add a setName setter. The problem is that $row->name" may still be used directly from the outside, which I don't like.
What is the recommended approach?
I thought about modifying __set and __get in My_Db_Table_Row to check for a setter/getter and automatically use that, if available. This would maintain BC for code using my rows, but is quite misleading since it looks like you're accessing a simple property, when in fact you're invoking a method (which might cause side effects).
Another idea was to modify __set and __get to just disallow direct manipulation if a setter/getter is present and throw an exeption, which would be functionally equivalent to making the property protected/private (except that it can't be used from within a class either).
Will anything be done in this direction in ZF?
Regards,
Jaka
没有评论:
发表评论