diff --git a/src/Api/Actions/Activity/IndexAction.php b/src/Api/Actions/Activity/IndexAction.php index 52bf7354e..0daf5d104 100644 --- a/src/Api/Actions/Activity/IndexAction.php +++ b/src/Api/Actions/Activity/IndexAction.php @@ -19,17 +19,12 @@ class IndexAction extends SerializeCollectionAction protected $activity; /** - * The name of the serializer class to output results with. - * - * @var string + * @inheritdoc */ public static $serializer = 'Flarum\Api\Serializers\ActivitySerializer'; /** - * The relationships that are available to be included, and which ones are - * included by default. - * - * @var array + * @inheritdoc */ public static $include = [ 'subject' => true, @@ -38,12 +33,30 @@ class IndexAction extends SerializeCollectionAction ]; /** - * The relations that are linked by default. - * - * @var array + * @inheritdoc */ public static $link = ['user']; + /** + * @inheritdoc + */ + public static $limitMax = 50; + + /** + * @inheritdoc + */ + public static $limit = 20; + + /** + * @inheritdoc + */ + public static $sortFields = []; + + /** + * @inheritdoc + */ + public static $sort; + /** * Instantiate the action. * diff --git a/src/Api/Actions/Discussions/CreateAction.php b/src/Api/Actions/Discussions/CreateAction.php index 36b1815ec..b69f7c9b0 100644 --- a/src/Api/Actions/Discussions/CreateAction.php +++ b/src/Api/Actions/Discussions/CreateAction.php @@ -24,17 +24,12 @@ class CreateAction extends BaseCreateAction protected $forum; /** - * The name of the serializer class to output results with. - * - * @var string + * @inheritdoc */ public static $serializer = 'Flarum\Api\Serializers\DiscussionSerializer'; /** - * The relationships that are available to be included, and which ones are - * included by default. - * - * @var array + * @inheritdoc */ public static $include = [ 'posts' => true, @@ -44,6 +39,31 @@ class CreateAction extends BaseCreateAction 'lastPost' => true ]; + /** + * @inheritdoc + */ + public static $link = []; + + /** + * @inheritdoc + */ + public static $limitMax = 50; + + /** + * @inheritdoc + */ + public static $limit = 20; + + /** + * @inheritdoc + */ + public static $sortFields = []; + + /** + * @inheritdoc + */ + public static $sort; + /** * Instantiate the action. * diff --git a/src/Api/Actions/Discussions/IndexAction.php b/src/Api/Actions/Discussions/IndexAction.php index 77f6ce578..68dc70241 100644 --- a/src/Api/Actions/Discussions/IndexAction.php +++ b/src/Api/Actions/Discussions/IndexAction.php @@ -24,17 +24,12 @@ class IndexAction extends SerializeCollectionAction protected $url; /** - * The name of the serializer class to output results with. - * - * @var string + * @inheritdoc */ public static $serializer = 'Flarum\Api\Serializers\DiscussionSerializer'; /** - * The relationships that are available to be included, and which ones are - * included by default. - * - * @var array + * @inheritdoc */ public static $include = [ 'startUser' => true, @@ -47,12 +42,30 @@ class IndexAction extends SerializeCollectionAction ]; /** - * The fields that are available to be sorted by. - * - * @var array + * @inheritdoc + */ + public static $link = []; + + /** + * @inheritdoc + */ + public static $limitMax = 50; + + /** + * @inheritdoc + */ + public static $limit = 20; + + /** + * @inheritdoc */ public static $sortFields = ['lastTime', 'commentsCount', 'startTime']; + /** + * @inheritdoc + */ + public static $sort; + /** * Instantiate the action. * diff --git a/src/Api/Actions/Discussions/ShowAction.php b/src/Api/Actions/Discussions/ShowAction.php index 06e6f1dbf..d1e4704a5 100644 --- a/src/Api/Actions/Discussions/ShowAction.php +++ b/src/Api/Actions/Discussions/ShowAction.php @@ -22,17 +22,12 @@ class ShowAction extends SerializeResourceAction protected $posts; /** - * The name of the serializer class to output results with. - * - * @var string + * @inheritdoc */ public static $serializer = 'Flarum\Api\Serializers\DiscussionSerializer'; /** - * The relationships that are available to be included, and which ones are - * included by default. - * - * @var array + * @inheritdoc */ public static $include = [ 'startUser' => false, @@ -47,23 +42,27 @@ class ShowAction extends SerializeResourceAction ]; /** - * The relations that are linked by default. - * - * @var array + * @inheritdoc */ public static $link = ['posts', 'posts.discussion']; /** - * The fields that are available to be sorted by. - * - * @var array + * @inheritdoc + */ + public static $limitMax = 50; + + /** + * @inheritdoc + */ + public static $limit = 20; + + /** + * @inheritdoc */ public static $sortFields = ['time']; /** - * The default sort field and order to user. - * - * @var string + * @inheritdoc */ public static $sort = ['time' => 'asc']; diff --git a/src/Api/Actions/Discussions/UpdateAction.php b/src/Api/Actions/Discussions/UpdateAction.php index e47b87ad4..c98745ae4 100644 --- a/src/Api/Actions/Discussions/UpdateAction.php +++ b/src/Api/Actions/Discussions/UpdateAction.php @@ -15,22 +15,43 @@ class UpdateAction extends SerializeResourceAction protected $bus; /** - * The name of the serializer class to output results with. - * - * @var string + * @inheritdoc */ public static $serializer = 'Flarum\Api\Serializers\DiscussionSerializer'; /** - * The relations that are included by default. - * - * @var array + * @inheritdoc */ public static $include = [ 'addedPosts' => true, 'addedPosts.user' => true ]; + /** + * @inheritdoc + */ + public static $link = []; + + /** + * @inheritdoc + */ + public static $limitMax = 50; + + /** + * @inheritdoc + */ + public static $limit = 20; + + /** + * @inheritdoc + */ + public static $sortFields = []; + + /** + * @inheritdoc + */ + public static $sort; + /** * Instantiate the action. * diff --git a/src/Api/Actions/Forum/ShowAction.php b/src/Api/Actions/Forum/ShowAction.php index be92a6c5f..5875e54c6 100644 --- a/src/Api/Actions/Forum/ShowAction.php +++ b/src/Api/Actions/Forum/ShowAction.php @@ -7,12 +7,40 @@ use Tobscure\JsonApi\Document; class ShowAction extends SerializeResourceAction { /** - * The name of the serializer class to output results with. - * - * @var string + * @inheritdoc */ public static $serializer = 'Flarum\Api\Serializers\ForumSerializer'; + /** + * @inheritdoc + */ + public static $include = []; + + /** + * @inheritdoc + */ + public static $link = []; + + /** + * @inheritdoc + */ + public static $limitMax = 50; + + /** + * @inheritdoc + */ + public static $limit = 20; + + /** + * @inheritdoc + */ + public static $sortFields = []; + + /** + * @inheritdoc + */ + public static $sort; + /** * Get the forum, ready to be serialized and assigned to the JsonApi * response. diff --git a/src/Api/Actions/Groups/IndexAction.php b/src/Api/Actions/Groups/IndexAction.php index 445e9d79f..a614dbd71 100644 --- a/src/Api/Actions/Groups/IndexAction.php +++ b/src/Api/Actions/Groups/IndexAction.php @@ -8,12 +8,40 @@ use Tobscure\JsonApi\Document; class IndexAction extends SerializeCollectionAction { /** - * The name of the serializer class to output results with. - * - * @var string + * @inheritdoc */ public static $serializer = 'Flarum\Api\Serializers\GroupSerializer'; + /** + * @inheritdoc + */ + public static $include = []; + + /** + * @inheritdoc + */ + public static $link = []; + + /** + * @inheritdoc + */ + public static $limitMax = 50; + + /** + * @inheritdoc + */ + public static $limit = 20; + + /** + * @inheritdoc + */ + public static $sortFields = []; + + /** + * @inheritdoc + */ + public static $sort; + /** * Get the groups, ready to be serialized and assigned to the document * response. diff --git a/src/Api/Actions/Notifications/IndexAction.php b/src/Api/Actions/Notifications/IndexAction.php index 5197bb7fa..0ea41ff92 100644 --- a/src/Api/Actions/Notifications/IndexAction.php +++ b/src/Api/Actions/Notifications/IndexAction.php @@ -14,16 +14,12 @@ class IndexAction extends SerializeCollectionAction protected $notifications; /** - * The name of the serializer class to output results with. - * - * @var string + * @inheritdoc */ public static $serializer = 'Flarum\Api\Serializers\NotificationSerializer'; /** - * The relations that are included by default. - * - * @var array + * @inheritdoc */ public static $include = [ 'sender' => true, @@ -32,19 +28,30 @@ class IndexAction extends SerializeCollectionAction ]; /** - * The maximum number of records that can be requested. - * - * @var integer + * @inheritdoc + */ + public static $link = []; + + /** + * @inheritdoc */ public static $limitMax = 50; /** - * The number of records included by default. - * - * @var integer + * @inheritdoc */ public static $limit = 10; + /** + * @inheritdoc + */ + public static $sortFields = []; + + /** + * @inheritdoc + */ + public static $sort; + /** * Instantiate the action. * diff --git a/src/Api/Actions/Notifications/UpdateAction.php b/src/Api/Actions/Notifications/UpdateAction.php index bd86a70b1..def34a0e3 100644 --- a/src/Api/Actions/Notifications/UpdateAction.php +++ b/src/Api/Actions/Notifications/UpdateAction.php @@ -14,12 +14,40 @@ class UpdateAction extends SerializeResourceAction protected $bus; /** - * The name of the serializer class to output results with. - * - * @var string + * @inheritdoc */ public static $serializer = 'Flarum\Api\Serializers\NotificationSerializer'; + /** + * @inheritdoc + */ + public static $include = []; + + /** + * @inheritdoc + */ + public static $link = []; + + /** + * @inheritdoc + */ + public static $limitMax = 50; + + /** + * @inheritdoc + */ + public static $limit = 20; + + /** + * @inheritdoc + */ + public static $sortFields = []; + + /** + * @inheritdoc + */ + public static $sort; + /** * Instantiate the action. * diff --git a/src/Api/Actions/Posts/CreateAction.php b/src/Api/Actions/Posts/CreateAction.php index 78b7094bc..76eccc373 100644 --- a/src/Api/Actions/Posts/CreateAction.php +++ b/src/Api/Actions/Posts/CreateAction.php @@ -14,16 +14,42 @@ class CreateAction extends BaseCreateAction protected $bus; /** - * The name of the serializer class to output results with. - * - * @var string + * @inheritdoc */ public static $serializer = 'Flarum\Api\Serializers\PostSerializer'; + /** + * @inheritdoc + */ public static $include = [ 'user' => true ]; + /** + * @inheritdoc + */ + public static $link = []; + + /** + * @inheritdoc + */ + public static $limitMax = 50; + + /** + * @inheritdoc + */ + public static $limit = 20; + + /** + * @inheritdoc + */ + public static $sortFields = []; + + /** + * @inheritdoc + */ + public static $sort; + /** * Instantiate the action. * diff --git a/src/Api/Actions/Posts/IndexAction.php b/src/Api/Actions/Posts/IndexAction.php index 7bea440e9..a99813197 100644 --- a/src/Api/Actions/Posts/IndexAction.php +++ b/src/Api/Actions/Posts/IndexAction.php @@ -15,17 +15,12 @@ class IndexAction extends SerializeCollectionAction protected $posts; /** - * The name of the serializer class to output results with. - * - * @var string + * @inheritdoc */ public static $serializer = 'Flarum\Api\Serializers\PostSerializer'; /** - * The relationships that are available to be included, and which ones are - * included by default. - * - * @var array + * @inheritdoc */ public static $include = [ 'user' => true, @@ -35,6 +30,31 @@ class IndexAction extends SerializeCollectionAction 'discussion' => true ]; + /** + * @inheritdoc + */ + public static $link = []; + + /** + * @inheritdoc + */ + public static $limitMax = 50; + + /** + * @inheritdoc + */ + public static $limit = 20; + + /** + * @inheritdoc + */ + public static $sortFields = []; + + /** + * @inheritdoc + */ + public static $sort; + /** * Instantiate the action. * diff --git a/src/Api/Actions/Posts/ShowAction.php b/src/Api/Actions/Posts/ShowAction.php index 104af500e..0e6c560f8 100644 --- a/src/Api/Actions/Posts/ShowAction.php +++ b/src/Api/Actions/Posts/ShowAction.php @@ -14,17 +14,12 @@ class ShowAction extends SerializeResourceAction protected $posts; /** - * The name of the serializer class to output results with. - * - * @var string + * @inheritdoc */ public static $serializer = 'Flarum\Api\Serializers\PostSerializer'; /** - * The relationships that are available to be included, and which ones are - * included by default. - * - * @var array + * @inheritdoc */ public static $include = [ 'user' => true, @@ -34,6 +29,31 @@ class ShowAction extends SerializeResourceAction 'discussion' => false ]; + /** + * @inheritdoc + */ + public static $link = []; + + /** + * @inheritdoc + */ + public static $limitMax = 50; + + /** + * @inheritdoc + */ + public static $limit = 20; + + /** + * @inheritdoc + */ + public static $sortFields = []; + + /** + * @inheritdoc + */ + public static $sort; + /** * Instantiate the action. * diff --git a/src/Api/Actions/Posts/UpdateAction.php b/src/Api/Actions/Posts/UpdateAction.php index 9df3d5b20..99f8ebdb1 100644 --- a/src/Api/Actions/Posts/UpdateAction.php +++ b/src/Api/Actions/Posts/UpdateAction.php @@ -14,12 +14,40 @@ class UpdateAction extends SerializeResourceAction protected $bus; /** - * The name of the serializer class to output results with. - * - * @var string + * @inheritdoc */ public static $serializer = 'Flarum\Api\Serializers\PostSerializer'; + /** + * @inheritdoc + */ + public static $include = []; + + /** + * @inheritdoc + */ + public static $link = []; + + /** + * @inheritdoc + */ + public static $limitMax = 50; + + /** + * @inheritdoc + */ + public static $limit = 20; + + /** + * @inheritdoc + */ + public static $sortFields = []; + + /** + * @inheritdoc + */ + public static $sort; + /** * Instantiate the action. * diff --git a/src/Api/Actions/Users/CreateAction.php b/src/Api/Actions/Users/CreateAction.php index 8682aabcc..fc3e48170 100644 --- a/src/Api/Actions/Users/CreateAction.php +++ b/src/Api/Actions/Users/CreateAction.php @@ -23,12 +23,40 @@ class CreateAction extends BaseCreateAction protected $forum; /** - * The name of the serializer class to output results with. - * - * @var string + * @inheritdoc */ public static $serializer = 'Flarum\Api\Serializers\UserSerializer'; + /** + * @inheritdoc + */ + public static $include = []; + + /** + * @inheritdoc + */ + public static $link = []; + + /** + * @inheritdoc + */ + public static $limitMax = 50; + + /** + * @inheritdoc + */ + public static $limit = 20; + + /** + * @inheritdoc + */ + public static $sortFields = []; + + /** + * @inheritdoc + */ + public static $sort; + /** * Instantiate the action. * diff --git a/src/Api/Actions/Users/DeleteAvatarAction.php b/src/Api/Actions/Users/DeleteAvatarAction.php index 69f48eda4..0529ba1f8 100644 --- a/src/Api/Actions/Users/DeleteAvatarAction.php +++ b/src/Api/Actions/Users/DeleteAvatarAction.php @@ -14,9 +14,7 @@ class DeleteAvatarAction extends SerializeResourceAction protected $bus; /** - * The name of the serializer class to output results with. - * - * @var string + * @inheritdoc */ public static $serializer = 'Flarum\Api\Serializers\UserSerializer'; diff --git a/src/Api/Actions/Users/IndexAction.php b/src/Api/Actions/Users/IndexAction.php index fab722ceb..8626978f3 100644 --- a/src/Api/Actions/Users/IndexAction.php +++ b/src/Api/Actions/Users/IndexAction.php @@ -23,6 +23,43 @@ class IndexAction extends SerializeCollectionAction */ protected $url; + /** + * @inheritdoc + */ + public static $serializer = 'Flarum\Api\Serializers\UserSerializer'; + + /** + * @inheritdoc + */ + public static $include = [ + 'groups' => true + ]; + + /** + * @inheritdoc + */ + public static $link = []; + + /** + * @inheritdoc + */ + public static $limitMax = 50; + + /** + * @inheritdoc + */ + public static $limit = 20; + + /** + * @inheritdoc + */ + public static $sortFields = ['username', 'postsCount', 'discussionsCount', 'lastSeenTime', 'joinTime']; + + /** + * @inheritdoc + */ + public static $sort; + /** * Instantiate the action. * @@ -35,30 +72,6 @@ class IndexAction extends SerializeCollectionAction $this->url = $url; } - /** - * The name of the serializer class to output results with. - * - * @var string - */ - public static $serializer = 'Flarum\Api\Serializers\UserSerializer'; - - /** - * The relationships that are available to be included, and which ones are - * included by default. - * - * @var array - */ - public static $include = [ - 'groups' => true - ]; - - /** - * The fields that are available to be sorted by. - * - * @var array - */ - public static $sortFields = ['username', 'postsCount', 'discussionsCount', 'lastSeenTime', 'joinTime']; - /** * Get the user results, ready to be serialized and assigned to the * document response. @@ -77,15 +90,11 @@ class IndexAction extends SerializeCollectionAction $results = $this->searcher->search($criteria, $request->limit, $request->offset, $request->include); - if (($total = $results->getTotal()) !== null) { - $document->addMeta('total', $total); - } - static::addPaginationLinks( $document, $request, $this->url->toRoute('flarum.api.users.index'), - $total ?: $results->areMoreResults() + $results->areMoreResults() ); return $results->getUsers(); diff --git a/src/Api/Actions/Users/ShowAction.php b/src/Api/Actions/Users/ShowAction.php index 79a14ce6d..931bc6210 100644 --- a/src/Api/Actions/Users/ShowAction.php +++ b/src/Api/Actions/Users/ShowAction.php @@ -13,24 +13,42 @@ class ShowAction extends SerializeResourceAction protected $users; /** - * The name of the serializer class to output results with. - * - * @var string + * @inheritdoc */ public static $serializer = 'Flarum\Api\Serializers\CurrentUserSerializer'; /** - * The relationships that are available to be included, and which ones are - * included by default. - * - * @var array + * @inheritdoc */ public static $include = [ 'groups' => true ]; + /** + * @inheritdoc + */ public static $link = []; + /** + * @inheritdoc + */ + public static $limitMax = 50; + + /** + * @inheritdoc + */ + public static $limit = 20; + + /** + * @inheritdoc + */ + public static $sortFields = []; + + /** + * @inheritdoc + */ + public static $sort; + /** * Instantiate the action. * diff --git a/src/Api/Actions/Users/UpdateAction.php b/src/Api/Actions/Users/UpdateAction.php index 4e7b0911a..64e732bdc 100644 --- a/src/Api/Actions/Users/UpdateAction.php +++ b/src/Api/Actions/Users/UpdateAction.php @@ -14,12 +14,40 @@ class UpdateAction extends SerializeResourceAction protected $bus; /** - * The name of the serializer class to output results with. - * - * @var string + * @inheritdoc */ public static $serializer = 'Flarum\Api\Serializers\UserSerializer'; + /** + * @inheritdoc + */ + public static $include = []; + + /** + * @inheritdoc + */ + public static $link = []; + + /** + * @inheritdoc + */ + public static $limitMax = 50; + + /** + * @inheritdoc + */ + public static $limit = 20; + + /** + * @inheritdoc + */ + public static $sortFields = []; + + /** + * @inheritdoc + */ + public static $sort; + /** * Instantiate the action. * diff --git a/src/Api/Actions/Users/UploadAvatarAction.php b/src/Api/Actions/Users/UploadAvatarAction.php index e17ba8faa..ebf3b66f8 100644 --- a/src/Api/Actions/Users/UploadAvatarAction.php +++ b/src/Api/Actions/Users/UploadAvatarAction.php @@ -14,12 +14,40 @@ class UploadAvatarAction extends SerializeResourceAction protected $bus; /** - * The name of the serializer class to output results with. - * - * @var string + * @inheritdoc */ public static $serializer = 'Flarum\Api\Serializers\UserSerializer'; + /** + * @inheritdoc + */ + public static $include = []; + + /** + * @inheritdoc + */ + public static $link = []; + + /** + * @inheritdoc + */ + public static $limitMax = 50; + + /** + * @inheritdoc + */ + public static $limit = 20; + + /** + * @inheritdoc + */ + public static $sortFields = []; + + /** + * @inheritdoc + */ + public static $sort; + /** * Instantiate the action. *