public function sendNotification(OW_Event $event) { $params = $event->getParams(); $data = $event->getData(); $userId = $params['userId']; $itemEventParams = array_merge(array('data' => $data), $params); $itemEvent = new OW_Event('notifications.on_item_send', $params, $data); OW::getEventManager()->trigger($itemEvent); $notificationItem = $itemEvent->getParams(); $notificationItem['data'] = $itemEvent->getData(); $this->service->sendPermittedNotifications($userId, array($notificationItem)); }
public function run() { $users = $this->service->findUserIdListForSend(100); if (empty($users)) { return; } $listEvent = new BASE_CLASS_EventCollector('notifications.send_list', array('userIdList' => $users)); OW::getEventManager()->trigger($listEvent); $notifications = array(); foreach ($listEvent->getData() as $notification) { $itemEvent = new OW_Event('notifications.on_item_send', $notification, $notification['data']); OW::getEventManager()->trigger($itemEvent); $notification['data'] = $itemEvent->getData(); $notifications[$notification['userId']][] = $notification; } foreach ($notifications as $userId => $notificationList) { $this->service->sendPermittedNotifications($userId, $notificationList); } }