Created
June 10, 2015 17:38
-
-
Save Ponsjuh/dc002d6f504cb50974ae to your computer and use it in GitHub Desktop.
ZF2 - Fundamentals - EventManager
This file contains 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
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