Skip to content

Instantly share code, notes, and snippets.

@GodsBoss
Last active August 29, 2015 14:04
Show Gist options
  • Save GodsBoss/71994b5ed1c0b43a2a6d to your computer and use it in GitHub Desktop.
Save GodsBoss/71994b5ed1c0b43a2a6d to your computer and use it in GitHub Desktop.
Yii: Detaching all event handlers
<?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