コード例 #1
0
 /**
  * {@inheritdoc}
  */
 protected function data(ServerRequestInterface $request, Document $document)
 {
     $actor = $request->getAttribute('actor');
     if ($actor->isGuest()) {
         throw new PermissionDeniedException();
     }
     $actor->markNotificationsAsRead()->save();
     $limit = $this->extractLimit($request);
     $offset = $this->extractOffset($request);
     $include = $this->extractInclude($request);
     return $this->notifications->findByUser($actor, $limit, $offset)->load($include);
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 protected function data(ServerRequestInterface $request, Document $document)
 {
     $actor = $request->getAttribute('actor');
     if ($actor->isGuest()) {
         throw new PermissionDeniedException();
     }
     $actor->markNotificationsAsRead()->save();
     $limit = $this->extractLimit($request);
     $offset = $this->extractOffset($request);
     $include = $this->extractInclude($request);
     $notifications = $this->notifications->findByUser($actor, $limit, $offset)->load(array_diff($include, ['subject.discussion']))->all();
     if (in_array('subject.discussion', $include)) {
         $this->loadSubjectDiscussions($notifications);
     }
     return $notifications;
 }
コード例 #3
0
 /**
  * @param ReadAllNotifications $command
  * @throws \Flarum\Core\Exception\PermissionDeniedException
  */
 public function handle(ReadAllNotifications $command)
 {
     $actor = $command->actor;
     $this->assertRegistered($actor);
     $this->notifications->markAllAsRead($actor);
 }