Based on the comments to @Andrew's answer, while your controller extends AbstractActionController (which most likely does), it already knows the EventManager, so you can simply fire any event that you like in the controller action by simply executing ...
<?php namespace Application/Controller; // usual use statements omitted for brevity .. class IndexController extends AbstractActionController { public function indexAction() { // trigger MyEvent $this->getEventManager()->trigger('MyEvent', $this); } }
To listen to this event in the bootstrap of some other module:
public function onBootstrap(EventInterface $e) { $app = $e->getApplication(); // get the shared events manager $sem = $app->getEventManager()->getSharedManager(); // listen to 'MyEvent' when triggered by the IndexController $sem->attach('Application\Controller\IndexController', 'MyEvent', function($e) { // do something... }); }
source share