|
|
@ -18,7 +18,7 @@ namespace yii\base; |
|
|
|
* and/or a setter method (e.g. `setLabel`). For example, the following |
|
|
|
* and/or a setter method (e.g. `setLabel`). For example, the following |
|
|
|
* getter and setter methods define a property named `label`: |
|
|
|
* getter and setter methods define a property named `label`: |
|
|
|
* |
|
|
|
* |
|
|
|
* ~~~php |
|
|
|
* ~~~ |
|
|
|
* private $_label; |
|
|
|
* private $_label; |
|
|
|
* |
|
|
|
* |
|
|
|
* public function getLabel() |
|
|
|
* public function getLabel() |
|
|
@ -36,7 +36,7 @@ namespace yii\base; |
|
|
|
* Reading or writing a property will cause the invocation of the corresponding |
|
|
|
* Reading or writing a property will cause the invocation of the corresponding |
|
|
|
* getter or setter method. For example, |
|
|
|
* getter or setter method. For example, |
|
|
|
* |
|
|
|
* |
|
|
|
* ~~~php |
|
|
|
* ~~~ |
|
|
|
* // equivalent to $label = $component->getLabel(); |
|
|
|
* // equivalent to $label = $component->getLabel(); |
|
|
|
* $label = $component->label; |
|
|
|
* $label = $component->label; |
|
|
|
* // equivalent to $component->setLabel('abc'); |
|
|
|
* // equivalent to $component->setLabel('abc'); |
|
|
@ -49,7 +49,7 @@ namespace yii\base; |
|
|
|
* (called *event handlers*) attached to the event will be invoked automatically. |
|
|
|
* (called *event handlers*) attached to the event will be invoked automatically. |
|
|
|
* The `on` method is typically declared like the following: |
|
|
|
* The `on` method is typically declared like the following: |
|
|
|
* |
|
|
|
* |
|
|
|
* ~~~php |
|
|
|
* ~~~ |
|
|
|
* public function onClick($event) |
|
|
|
* public function onClick($event) |
|
|
|
* { |
|
|
|
* { |
|
|
|
* $this->raiseEvent('onClick', $event); |
|
|
|
* $this->raiseEvent('onClick', $event); |
|
|
@ -63,7 +63,7 @@ namespace yii\base; |
|
|
|
* |
|
|
|
* |
|
|
|
* An event handler should be defined with the following signature: |
|
|
|
* An event handler should be defined with the following signature: |
|
|
|
* |
|
|
|
* |
|
|
|
* ~~~php |
|
|
|
* ~~~ |
|
|
|
* public function foo($event) { ... } |
|
|
|
* public function foo($event) { ... } |
|
|
|
* ~~~ |
|
|
|
* ~~~ |
|
|
|
* |
|
|
|
* |
|
|
@ -72,14 +72,14 @@ namespace yii\base; |
|
|
|
* To attach an event handler to an event, call [[attachEventHandler]]. |
|
|
|
* To attach an event handler to an event, call [[attachEventHandler]]. |
|
|
|
* Alternatively, you can also do the following: |
|
|
|
* Alternatively, you can also do the following: |
|
|
|
* |
|
|
|
* |
|
|
|
* ~~~php |
|
|
|
* ~~~ |
|
|
|
* $component->onClick = $callback; |
|
|
|
* $component->onClick = $callback; |
|
|
|
* // or $component->onClick->add($callback); |
|
|
|
* // or $component->onClick->add($callback); |
|
|
|
* ~~~ |
|
|
|
* ~~~ |
|
|
|
* |
|
|
|
* |
|
|
|
* where `$callback` refers to a valid PHP callback. Some examples of `$callback` are: |
|
|
|
* where `$callback` refers to a valid PHP callback. Some examples of `$callback` are: |
|
|
|
* |
|
|
|
* |
|
|
|
* ~~~php |
|
|
|
* ~~~ |
|
|
|
* 'handleOnClick' // handleOnClick() is a global function |
|
|
|
* 'handleOnClick' // handleOnClick() is a global function |
|
|
|
* array($object, 'handleOnClick') // $object->handleOnClick() |
|
|
|
* array($object, 'handleOnClick') // $object->handleOnClick() |
|
|
|
* array('Page', 'handleOnClick') // Page::handleOnClick() |
|
|
|
* array('Page', 'handleOnClick') // Page::handleOnClick() |
|
|
@ -375,9 +375,10 @@ class Component |
|
|
|
* You may manipulate the returned [[Vector]] object by adding or removing handlers. |
|
|
|
* You may manipulate the returned [[Vector]] object by adding or removing handlers. |
|
|
|
* For example, |
|
|
|
* For example, |
|
|
|
* |
|
|
|
* |
|
|
|
* ~~~php |
|
|
|
* ~~~ |
|
|
|
* $component->getEventHandlers($eventName)->insertAt(0, $eventHandler); |
|
|
|
* $component->getEventHandlers($eventName)->insertAt(0, $eventHandler); |
|
|
|
* ~~~ |
|
|
|
* ~~~ |
|
|
|
|
|
|
|
* |
|
|
|
* @param string $name the event name |
|
|
|
* @param string $name the event name |
|
|
|
* @return Vector list of attached event handlers for the event |
|
|
|
* @return Vector list of attached event handlers for the event |
|
|
|
* @throws Exception if the event is not defined |
|
|
|
* @throws Exception if the event is not defined |
|
|
@ -399,14 +400,14 @@ class Component |
|
|
|
* |
|
|
|
* |
|
|
|
* This is equivalent to the following code: |
|
|
|
* This is equivalent to the following code: |
|
|
|
* |
|
|
|
* |
|
|
|
* ~~~php |
|
|
|
* ~~~ |
|
|
|
* $component->getEventHandlers($eventName)->add($eventHandler); |
|
|
|
* $component->getEventHandlers($eventName)->add($eventHandler); |
|
|
|
* ~~~ |
|
|
|
* ~~~ |
|
|
|
* |
|
|
|
* |
|
|
|
* An event handler must be a valid PHP callback. The followings are |
|
|
|
* An event handler must be a valid PHP callback. The followings are |
|
|
|
* some examples: |
|
|
|
* some examples: |
|
|
|
* |
|
|
|
* |
|
|
|
* ~~~php |
|
|
|
* ~~~ |
|
|
|
* 'handleOnClick' // handleOnClick() is a global function |
|
|
|
* 'handleOnClick' // handleOnClick() is a global function |
|
|
|
* array($object, 'handleOnClick') // $object->handleOnClick() |
|
|
|
* array($object, 'handleOnClick') // $object->handleOnClick() |
|
|
|
* array('Page', 'handleOnClick') // Page::handleOnClick() |
|
|
|
* array('Page', 'handleOnClick') // Page::handleOnClick() |
|
|
@ -415,7 +416,7 @@ class Component |
|
|
|
* |
|
|
|
* |
|
|
|
* An event handler must be defined with the following signature, |
|
|
|
* An event handler must be defined with the following signature, |
|
|
|
* |
|
|
|
* |
|
|
|
* ~~~php |
|
|
|
* ~~~ |
|
|
|
* function handlerName($event) {} |
|
|
|
* function handlerName($event) {} |
|
|
|
* ~~~ |
|
|
|
* ~~~ |
|
|
|
* |
|
|
|
* |
|
|
@ -624,7 +625,7 @@ class Component |
|
|
|
* |
|
|
|
* |
|
|
|
* If a PHP callback is used, the corresponding function/method signature should be |
|
|
|
* If a PHP callback is used, the corresponding function/method signature should be |
|
|
|
* |
|
|
|
* |
|
|
|
* ~~~php |
|
|
|
* ~~~ |
|
|
|
* function foo($param1, $param2, ..., $component) { ... } |
|
|
|
* function foo($param1, $param2, ..., $component) { ... } |
|
|
|
* ~~~ |
|
|
|
* ~~~ |
|
|
|
* |
|
|
|
* |
|
|
|