yii\base\Behavior::events PHP Method

events() public method

Child classes may override this method to declare what PHP callbacks should be attached to the events of the [[owner]] component. The callbacks will be attached to the [[owner]]'s events when the behavior is attached to the owner; and they will be detached from the events when the behavior is detached from the component. The callbacks can be any of the following: - method in this behavior: 'handleClick', equivalent to [$this, 'handleClick'] - object method: [$object, 'handleClick'] - static method: ['Page', 'handleClick'] - anonymous function: function ($event) { ... } The following is an example: php [ Model::EVENT_BEFORE_VALIDATE => 'myBeforeValidate', Model::EVENT_AFTER_VALIDATE => 'myAfterValidate', ]
public events ( ) : array
return array events (array keys) and the corresponding event handler methods (array values).
    public function events()
    {
        return [];
    }

Usage Example

Beispiel #1
0
 public function events()
 {
     $owner = $this->owner;
     if ($owner instanceof Controller) {
         return [$owner::EVENT_BEFORE_ACTION => '', $owner::EVENT_AFTER_ACTION => ''];
     }
     return parent::events();
 }
All Usage Examples Of yii\base\Behavior::events