_owner=$owner; foreach($this->events() as $event=>$handler) $owner->attachEventHandler($event,array($this,$handler)); } /** * Detaches the behavior object from the component. * The default implementation will unset the {@link owner} property * and detach event handlers declared in {@link events}. * Make sure you call the parent implementation if you override this method. * @param CComponent $owner the component that this behavior is to be detached from. */ public function detach($owner) { foreach($this->events() as $event=>$handler) $owner->detachEventHandler($event,array($this,$handler)); $this->_owner=null; } /** * @return CComponent the owner component that this behavior is attached to. */ public function getOwner() { return $this->_owner; } /** * @return boolean whether this behavior is enabled */ public function getEnabled() { return $this->_enabled; } /** * @param boolean $value whether this behavior is enabled */ public function setEnabled($value) { if($this->_enabled!=$value && $this->_owner) { if($value) { foreach($this->events() as $event=>$handler) $this->_owner->attachEventHandler($event,array($this,$handler)); } else { foreach($this->events() as $event=>$handler) $this->_owner->detachEventHandler($event,array($this,$handler)); } } $this->_enabled=$value; } }