the browser-facing portion of osu!
at master 1.4 kB view raw
1<?php 2 3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0. 4// See the LICENCE file in the repository root for full licence text. 5 6namespace App\Libraries; 7 8abstract class BeatmapsetDiscussionsBundleBase 9{ 10 protected $isModerator; 11 protected $paginator; 12 protected $params; 13 14 public function __construct(array $params) 15 { 16 $this->params = $params; 17 18 $this->isModerator = priv_check('BeatmapDiscussionModerate')->can(); 19 if ($this->isModerator) { 20 // TODO: normalize with mail beatmap discussions behaviour (discussion by restricted user visible for all users, name is not). 21 $this->params['is_moderator'] = true; 22 } else { 23 $this->params['with_deleted'] = false; 24 } 25 } 26 27 /** 28 * That main paginated dataset for the bundle. 29 */ 30 abstract public function getData(); 31 32 public function getPaginator() 33 { 34 if ($this->paginator === null) { 35 $this->getData(); 36 } 37 38 return $this->paginator; 39 } 40 41 protected function getCursor() 42 { 43 $paginator = $this->getPaginator(); 44 return $paginator->hasMorePages() ? [ 45 // TODO: move to non-offset 46 'page' => $paginator->currentPage() + 1, 47 'limit' => $paginator->perPage(), 48 ] : null; 49 } 50}