To remove a behavior, call the yiibaseComponent: detachBehavior () method and use the name associated with the behavior: $ component-detachBehavior (myBehavior1). You can also remove all behaviors: $ component-detachBehaviors (); both of the above two methods call yiibaseBehavior: detach ().
To remove a behavior, call the yii \ base \ Component: detachBehavior () method and use the name associated with the behavior: $ component-detachBehavior ('mybehavior1 '); you can also remove all Behavior: $ component-detachBehaviors (); both of the above two methods call yii \ base \ Behavior: detach (), which
To remove a behavior, you can call the yii \ base \ Component: detachBehavior () method to implement it with the name associated with the behavior:
$component->detachBehavior('myBehavior1');
You can also remove all actions:
$component->detachBehaviors();
The preceding two methods call yii \ base \ Behavior: detach (). The Code is as follows:
Public function detach () {// this must be an action with a Master name. Only when the if ($ this-> owner) {// traverses the event defined by the behavior, revoke foreach ($ this-> events () as $ event =>$ handler) {$ this-> owner-> off ($ event, is_string ($ handler )? [$ This, $ handler]: $ handler) ;}$ this-> owner = null ;}}
Unlike yii \ base \ Behavior: attach (), the process of Unbinding is to do two things: first, set $ owner to null, indicating that this Behavior is not attached to any class. The second is to remove the event hanlder bound to the class through the off () of Component. In a word, beginning and end.