You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/5.x/extend/events.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,12 @@ See [Using Events in a Custom Module](kb:custom-module-events) for an end-to-end
12
12
13
13
This page covers customizing Craft’s native behavior by registering event handlers in your plugin, and how to implement [your own events](#custom-events) that other developers can take advantage of.
14
14
15
+
## Event Code Generator
16
+
17
+
Quickly find events and generate code samples. Many events will appear more than once, as they’re listed for each class that emits them—read about [discovering events](#discovering-events) for more information!
18
+
19
+
<event-browsersource="craft-5" />
20
+
15
21
## Anatomy of an Event
16
22
17
23
We use “event” to describe the **name** and **sender** that uniquely identify it, as well as the actual <yii2:yii\base\Event> instance that is emitted.
@@ -67,7 +73,7 @@ The best way to discover an event is to get familiar with a known procedure by s
67
73
A fresh Craft install can easily emit 100 or more events per request, so using your IDE’s _conditional breakpoint_ may be necessary to cut down on noise!
68
74
:::
69
75
70
-
Directly searching the Craft source is a great way to learn about Craft-specific events—but it will miss a host of events emitted by Yii, as well as those that are inherited from parent classes. The [event browser](#event-code-generator) and generator below enumerates _all_ of those events, even if they’re technically defined by a parent.
76
+
Directly searching the Craft source is a great way to learn about Craft-specific events—but it will miss a host of events emitted by Yii, as well as those that are inherited from parent classes. The [event browser](#event-code-generator) and generator enumerates _all_ of those events, even if they’re technically defined by a parent.
71
77
72
78
### Inherited Events
73
79
@@ -233,12 +239,6 @@ $query->attachBehavior('myBehavior', new EventBehavior([
233
239
234
240
The second argument to the `EventBehavior` constructor tells the behavior to mimic <craft5:craft\base\Event::once()> and will only invoke your handler once. All handlers are treated the same way, but you may mix one-time and continuous handlers by attaching multiple `EventBehavior` instances.
235
241
236
-
## Event Code Generator
237
-
238
-
Select an event for more detail and a code snippet.
0 commit comments