getApplication(); $services = $application->getServiceManager(); $manager = $services->get('queue'); $events = $manager->getEventManager(); $events->attach( 'task.change', // this attaches us only to task.change events function ($event) use ($services) { // 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; } // hello world a number of strings in the event // all available fields are described in the Activity model in /Activity/src/Activity/Model/Activity.php $model->set('description', 'Hello World'); $model->set('action', 'helloed'); $model->set('target', 'World'); // you can write out to the log to help you debug your module. comment out the line below // $services->get('logger')->err("Writing to the log"); }, // set our priority, -90 puts us right before the end, but before the activity is published -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__, ), ), ); } }