Skip to content

Instantly share code, notes, and snippets.

@Ponsjuh
Created June 10, 2015 17:38
Show Gist options
  • Save Ponsjuh/dc002d6f504cb50974ae to your computer and use it in GitHub Desktop.
Save Ponsjuh/dc002d6f504cb50974ae to your computer and use it in GitHub Desktop.
ZF2 - Fundamentals - EventManager
public function indexAction()
{
$events = $this->getEventManager();
$events->attach('do', function($e) {
$event = $e->getName();
$target = get_class($e->getTarget());
$params = json_encode($e->getParams());
$params = $e->getParams();
printf("handled event '%s' with params %s", $event, json_encode($params));
});
$events->trigger('do', null, ['foo' => 'bar']);
return new ViewModel();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment