getApplication(); $services = $application->getServiceManager(); $manager = $services->get('queue'); $events = $manager->getEventManager(); $qualifiedUrl = $services->get('viewhelpermanager')->get('qualifiedUrl'); $events->attach( 'task.commit', // only fire on task.commit events function ($event) use ($services, $events) { // we need events and services for this module // provide the kato.im URL for your particular room here. $room = "https://api.kato.im/rooms/36284a1d50c33c4593c3932b7e5f6942d2e4bd1af990ceb204c9c41cfeea935/simple"; // sanity check to make sure this is a properly formed Activity event $model = $event->getParam('activity'); if (!$model instanceof Activity) { return; } // build up the message $change = $model->get('target'); $user = $model->get('user'); $description = $model->get('description'); $url = $qualifiedUrl('change', "12345"); $message = json_encode(ucfirst("[$change](" . $model->get('url') . ") submitted by $user\n\n$description")); $json = '{\"from\": \"Robot\", \"color\": \"green\", \"renderer\": \"markdown\", \"text\":' . str_replace("\"",'\"', $message) . ' }'; // some logging that may be handy for debugging // $services->get('logger')->err("/usr/bin/curl -X POST -d \"$json\" $room"); $services->get('logger')->err("$url"); // post the message to our room using curl exec("/usr/bin/curl -X POST -d \"$json\" $room"); return; }, // set our priority, -90 to put ourselves near the end of the event pipeline -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 // need to explicitly install our module in the application public function getAutoloaderConfig() { return array( 'Zend\Loader\StandardAutoloader' => array( 'namespaces' => array( __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__, ), ), ); } }