PHP 클래스 yii\base\Behavior

A behavior can be used to enhance the functionality of an existing component without modifying its code. In particular, it can "inject" its own methods and properties into the component and make them directly accessible via the component. It can also respond to the events triggered in the component and thus intercept the normal code execution. For more details and usage information on Behavior, see the guide article on behaviors.
부터: 2.0
저자: Qiang Xue ([email protected])
상속: extends Object
파일 보기 프로젝트 열기: yiisoft/yii2 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$owner the owner of this behavior

공개 메소드들

메소드 설명
attach ( Component $owner ) Attaches the behavior object to the component.
detach ( ) Detaches the behavior object from the component.
events ( ) : array Declares event handlers for the [[owner]]'s events.

메소드 상세

attach() 공개 메소드

The default implementation will set the [[owner]] property and attach event handlers as declared in [[events]]. Make sure you call the parent implementation if you override this method.
public attach ( Component $owner )
$owner Component the component that this behavior is to be attached to.

detach() 공개 메소드

The default implementation will unset the [[owner]] property and detach event handlers declared in [[events]]. Make sure you call the parent implementation if you override this method.
public detach ( )

events() 공개 메소드

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
리턴 array events (array keys) and the corresponding event handler methods (array values).

프로퍼티 상세

$owner 공개적으로 프로퍼티

the owner of this behavior
public $owner