Yii Framework Forum: Behavior Best Practice - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Behavior Best Practice Rate Topic: -----

#1 User is offline   Say_Ten 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 109
  • Joined: 17-September 10

Posted 17 September 2010 - 05:22 AM

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.
0

#2 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,589
  • Joined: 17-January 09
  • Location:Russia

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 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users