The method of removing the binding behavior of a component in the YII framework of PHP, the YII framework
To remove the behavior, you can call Yii\base\component: the:d Etachbehavior () method is implemented with the name associated with the behavior:
$component->detachbehavior (' MyBehavior1 ');
You can also remove all behaviors:
$component->detachbehaviors ();
Both of these methods will be called to Yii\base\behavior::d Etach (), with the following code:
Public Function Detach () { //This has to be a famous act of the Lord. Remove the if ($this->owner) { //traversal behavior-defined events, one-by-one to dismiss the foreach ($ This->events () as $event = $handler) { $this->owner->off ($event, is_string ($handler)? [$this, $handler]: $handler); } $this->owner = null; }}
In contrast to Yii\base\behavior::attach (), the process of dissolution is to do two things: one is to set the $owner to NULL, indicating that the behavior is not attached to any class. The second is to remove the event Hanlder bound to the class by component off (). In a word, finish.
Articles you may be interested in:
- The definition and binding methods of behavior in the YII framework of PHP
- A detailed approach to using behavioral behaviors in the PHP yii framework
- In-depth explanation of properties in the Yii framework of PHP
- PHP's YII framework uses database configuration and SQL Operations example tutorials
- In-depth parsing of event events mechanism in the YII framework of PHP
- Full interpretation of the log function in the YII framework of PHP
- Yii uses find FindAll to find out how to implement a specified field
- Analysis and modification of yii database by adding and deleting
- YII PHP Framework Practical Introductory Tutorial (detailed)
- Attribute injection and method injection of component behavior in PHP's YII framework
http://www.bkjia.com/PHPjc/1111896.html www.bkjia.com true http://www.bkjia.com/PHPjc/1111896.html techarticle PHP's Yii framework to remove the behavior of the component binding method, Yii framework to remove the behavior, you can call Yii\base\component::d Etachbehavior () method with the name of the behavior associated with the implementation of: ...