Last active
August 29, 2015 14:04
-
-
Save GodsBoss/71994b5ed1c0b43a2a6d to your computer and use it in GitHub Desktop.
Yii: Detaching all event handlers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class FooHandling extends CComponent | |
{ | |
public function onFoo($event) {} | |
} | |
function handlerOne($event){} | |
function handlerTwo($event){} | |
$component = new FooHandling(); | |
$component->attachEventHandler('onFoo', 'handlerOne'); | |
$component->attachEventHandler('onFoo', 'handlerTwo'); | |
$handlers = $component->getEventHandlers('onFoo'); | |
foreach ($handlers as $handler) { | |
$component->detachEventHandler('onFoo', $handler); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment