getApplication(); $services = $application->getServiceManager(); $manager = $services->get('queue'); $events = $manager->getEventManager(); $events->attach( 'task.change', // only fire on task.change events function ($event) use ($services, $events) { // we need events and services for this module // sanity check to make sure this is a properly formed Activity event $model = $event->getParam('activity'); if (!$model instanceof Activity) { return; } // if Andrew checks in, remind the world of my last very important change if ($model->get('user') == 'alau') { $p4 = $services->get('p4'); // there is a pre-built p4 connection waiting for us $changes = $p4->run('changes', array('-m1', '-s', 'submitted', '-u', 'matt')); // we run commands with flags just like from the command line foreach ($changes->getData() as $change) { $params = array('id' => $change['change']); $events->trigger('task.change', null, $params); // here we trigger a new change event using my last change number } } return; }, // set our priority, -70 puts us before the other sample modules -70 ); } // 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__, ), ), ); } }