Commit 468e4191 by Qiang Xue

events guide wip [skip ci]

parent f629faf9
......@@ -27,7 +27,7 @@ Getting Started
Basic Concepts
--------------
* [Object Properties](basic-properties.md)
* [Properties](basic-properties.md)
* [Events](basic-events.md)
* [Behaviors](basic-behaviors.md)
* [Object Configurations](basic-configs.md)
......
......@@ -158,3 +158,23 @@ widgets without specifying the class for every widget usage, you can do the foll
The code above should be executed once before `LinkPager` widget is used. It can be done in `index.php`, the application
configuration file, or anywhere else.
### Attaching event handlers via config
You can also attach event handlers within your configuration file. To do so, add an element to the component to which the handler should be attached. The syntax is `"on <event>" => handler`:
```php
return [
// ...
'components' => [
'db' => [
// ...
'on afterOpen' => function ($event) {
// do something right after connected to database
}
],
],
];
```
Object Properties
=================
Properties
==========
In PHP, class member variables are also called *properties*. They are part of a class definition and are used
to represent the state of a class instance. In practice, you may often want to do some special handling when
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment