getApplication(); $services = $application->getServiceManager(); $manager = $services->get('queue'); $events = $manager->getEventManager(); // we attach to all events. see the other examples for how to attach to specific events $events->attach( '*', // '*' here attaches us to all events function ($event) use ($services,$manager) { // we need both services and manager for this module // a lot of events come through. we need to make sure this is actually an activity event $model = $event->getParam('activity'); if (!$model instanceof Activity) { return; } // calling stopPropagation prevents the event from getting to the end of the line and being published if ($model->get('user') == 'alau') { $services->get('logger')->err("Lau smote"); $event->stopPropagation(true); return; } // note if we did nothing $services->get('logger')->err("No Lau to smite"); }, // set our priority, -90 puts us right before the end so Andrew can't sneak in easily -90 ); } // loads up our config file. all modules should have this method. public function getConfig() { return include __DIR__ . '/config/module.config.php'; } // makes sure our module is automatically loaded. otherwise the user would // explicitly install our module in the application public function getAutoloaderConfig() { return array( 'Zend\Loader\StandardAutoloader' => array( 'namespaces' => array( __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__, ), ), ); } }