Yii Framework Forum: Event Example from Documentation - Yii Framework Forum

Jump to content

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

Event Example from Documentation Rate Topic: ****- 1 Votes

#1 User is offline   JMarkMurphy 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 21-March 12

Posted 21 March 2012 - 11:00 PM

I was reading the documentation about Events and Behaviors. Very Interesting reading about Behaviors BTW. Still have to digest that. The comments have a "Real World Example" of an event. Basically an event is conditionally registered in the after save event, then a method is attached to the event, then the event is enabled in the controller. But why all the extra event handling? Couldn't I just call my method in the afterSave method? What is the advantage to all the extra event handling code?

I wanted to ask this question in context, but I am too new to post comments there.

Here is the page I am referring to: http://www.yiiframew...ehaviors-events
1

#2 User is offline   shailesh 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 79
  • Joined: 14-May 11
  • Location:Ahmedabad(India)

Posted 22 March 2012 - 04:43 AM

Bellowed URL MAy Help May More

http://www.yiiframew...asics.component
0

#3 User is offline   ametad 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 78
  • Joined: 08-February 12
  • Location:Holland

Posted 02 August 2012 - 07:27 AM

View PostJMarkMurphy, on 21 March 2012 - 11:00 PM, said:

I was reading the documentation about Events and Behaviors. Very Interesting reading about Behaviors BTW. Still have to digest that. The comments have a "Real World Example" of an event. Basically an event is conditionally registered in the after save event, then a method is attached to the event, then the event is enabled in the controller. But why all the extra event handling? Couldn't I just call my method in the afterSave method? What is the advantage to all the extra event handling code?

I wanted to ask this question in context, but I am too new to post comments there.

Here is the page I am referring to: http://www.yiiframew...ehaviors-events


After hours of reading I also don't get it (yet)... why use events when in the end you still have to invoke them manually :blink: And so it seems more logically to call the method directly.
I think I just don't get it.. What did make YOU (reader) understand Events in Yii? All help is welcome.
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