yii\base\Behavior::detach PHP Method

detach() public method

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 ( )
    public function detach()
    {
        if ($this->owner) {
            foreach ($this->events() as $event => $handler) {
                $this->owner->off($event, is_string($handler) ? [$this, $handler] : $handler);
            }
            $this->owner = null;
        }
    }

Usage Example

 public function detach()
 {
     /** @var UpdateAction $owner */
     $owner = $this->owner;
     $owner->controller->off(Controller::EVENT_AFTER_ACTION, [$this, 'handleConflict']);
     Event::off(ActiveRecord::className(), ActiveRecord::EVENT_INIT, [$this, 'onActiveRecordInit']);
     parent::detach();
 }
All Usage Examples Of yii\base\Behavior::detach