The method of removing the binding behavior of a component in PHP's Yii framework, the YII Framework _php Tutorial

Source: Internet
Author: User
Tags php framework

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: ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.