Look at the event and listener can not imagine the usual development process will be able to use them.
Can you tell us about their merits and usage scenarios?
Reply content:
Look at the event and listener can not imagine the usual development process will be able to use them.
Can you tell us about their merits and usage scenarios?
Listener refers to the monitoring of the model?
This is too much to use, such as statistics, how many posts are published today, how many users have been registered, what monitoring delete events to implement the global data Recycle Bin, etc...
event, it is equivalent to the controller layered. Abstract some logic code that might be reused, such as logging in and registering something. Because your login may be called in more than one method, such as registering to complete the automatic login, you can invoke the login event instead of invoking the Auth controller's login method. Because the login method of the Auth controller may have the verification code judgment and so on. But this automatic login is obviously not a need.
The simplest, the background administrator operation log, each time after the Operation event ()
In fact, this thing personal use is not much, just ordinary listening, actually with you call another method no difference
There are different types of evnet, such as model event, which can be used to monitor model changes in observer mode.