Just randomly I recently developed two behaviours, both took slightly different routes due to the way they evolved. The first added a method to get another object that when could be used to modify data related to the owner. The second added a series of methods to the owner that also modified data related to the owner. Now, my thinking is that having the behaviour return an object that you then utilise reduces the amount of methods you're adding to the owner and prevents potential clashing between behaviours. Whereas the other keeps things a little more simple and the behaviour is encapsulated within the model.
I'm looking for thoughts on best practice here.
Page 1 of 1
Behavior Best Practice
#2
Posted 17 September 2010 - 09:05 AM
Well, you can always call behavior methods explicitly to avoid clashing:
$model->taggable->setTags(array('PHP', 'Yii'));
Yii 2.0 Development Cookbook
Enjoying Yii? Star us at github
Support me so I can work more on Yii: https://www.patreon.com/samdark
Enjoying Yii? Star us at github
Support me so I can work more on Yii: https://www.patreon.com/samdark
Share this topic:
Page 1 of 1