Пример #1
0
 public function loadList(BASE_CLASS_ConsoleListEvent $event)
 {
     $params = $event->getParams();
     $data = $event->getData();
     $userId = OW::getUser()->getId();
     if ($params['target'] != self::CONSOLE_ITEM_KEY) {
         return;
     }
     $loadItemsCount = 10;
     $notifications = $this->service->findNotificationList($userId, $params['console']['time'], $params['ids'], $loadItemsCount);
     $notificationIds = array();
     $data['listFull'] = count($notifications) < $loadItemsCount;
     foreach ($notifications as $notification) {
         $notificationData = $notification->getData();
         $itemEvent = new OW_Event('notifications.on_item_render', array('key' => 'notification_' . $notification->id, 'entityType' => $notification->entityType, 'entityId' => $notification->entityId, 'pluginKey' => $notification->pluginKey, 'userId' => $notification->userId, 'viewed' => (bool) $notification->viewed, 'data' => $notificationData), $notificationData);
         OW::getEventManager()->trigger($itemEvent);
         $item = $itemEvent->getData();
         if (empty($item)) {
             continue;
         }
         $notificationIds[] = $notification->id;
         $event->addItem($item, $notification->id);
     }
     $event->setData($data);
     $this->service->markNotificationsViewedByIds($notificationIds);
 }