php - Using the event-manager with multiple 'attachments' -
i'm trying use zend event-manager , have attachments 2 classes. try trigger events , go thru every attached function. somehow i'm able receive 1 event , never other events. can please point me in right direction?
// create event-manager public static function geteventmanager() { if(!self::$eventmanager) { self::$eventmanager = new \zend_eventmanager_eventmanager(); } return self::$eventmanager; } // attach event item\plugin::geteventmanager()->attach("item.getprovider", function($e) { $item = $e->getparam("item"); return $this; }); // attach event in class item\plugin::geteventmanager()->attach("item.getprovider", function($e) { $item = $e->getparam("item"); return $this; }); // events attached $results = self::geteventmanager()->trigger("item.getprovider", null, array("item" => $item), function($v) { return ($v instanceof item); }); if($results->stopped()) { $provider = array(); foreach($results $result) { $provider[] = $result; } return $provider; } }
Comments
Post a Comment