mirror of
https://github.com/flarum/core.git
synced 2025-07-25 18:51:40 +02:00
Define static properties on SerializeAction subclasses
Explained in d1e7453ffd
.
If we ever come up with a better way of doing this it should be easy to
change over, since modification of these properties by extensions is
abstracted by an Extend API.
This commit is contained in:
@@ -19,17 +19,12 @@ class IndexAction extends SerializeCollectionAction
|
|||||||
protected $activity;
|
protected $activity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the serializer class to output results with.
|
* @inheritdoc
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
*/
|
||||||
public static $serializer = 'Flarum\Api\Serializers\ActivitySerializer';
|
public static $serializer = 'Flarum\Api\Serializers\ActivitySerializer';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The relationships that are available to be included, and which ones are
|
* @inheritdoc
|
||||||
* included by default.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
*/
|
||||||
public static $include = [
|
public static $include = [
|
||||||
'subject' => true,
|
'subject' => true,
|
||||||
@@ -38,12 +33,30 @@ class IndexAction extends SerializeCollectionAction
|
|||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The relations that are linked by default.
|
* @inheritdoc
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
*/
|
||||||
public static $link = ['user'];
|
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.
|
* Instantiate the action.
|
||||||
*
|
*
|
||||||
|
@@ -24,17 +24,12 @@ class CreateAction extends BaseCreateAction
|
|||||||
protected $forum;
|
protected $forum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the serializer class to output results with.
|
* @inheritdoc
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
*/
|
||||||
public static $serializer = 'Flarum\Api\Serializers\DiscussionSerializer';
|
public static $serializer = 'Flarum\Api\Serializers\DiscussionSerializer';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The relationships that are available to be included, and which ones are
|
* @inheritdoc
|
||||||
* included by default.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
*/
|
||||||
public static $include = [
|
public static $include = [
|
||||||
'posts' => true,
|
'posts' => true,
|
||||||
@@ -44,6 +39,31 @@ class CreateAction extends BaseCreateAction
|
|||||||
'lastPost' => true
|
'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.
|
* Instantiate the action.
|
||||||
*
|
*
|
||||||
|
@@ -24,17 +24,12 @@ class IndexAction extends SerializeCollectionAction
|
|||||||
protected $url;
|
protected $url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the serializer class to output results with.
|
* @inheritdoc
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
*/
|
||||||
public static $serializer = 'Flarum\Api\Serializers\DiscussionSerializer';
|
public static $serializer = 'Flarum\Api\Serializers\DiscussionSerializer';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The relationships that are available to be included, and which ones are
|
* @inheritdoc
|
||||||
* included by default.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
*/
|
||||||
public static $include = [
|
public static $include = [
|
||||||
'startUser' => true,
|
'startUser' => true,
|
||||||
@@ -47,12 +42,30 @@ class IndexAction extends SerializeCollectionAction
|
|||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The fields that are available to be sorted by.
|
* @inheritdoc
|
||||||
*
|
*/
|
||||||
* @var array
|
public static $link = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public static $limitMax = 50;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public static $limit = 20;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
public static $sortFields = ['lastTime', 'commentsCount', 'startTime'];
|
public static $sortFields = ['lastTime', 'commentsCount', 'startTime'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public static $sort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiate the action.
|
* Instantiate the action.
|
||||||
*
|
*
|
||||||
|
@@ -22,17 +22,12 @@ class ShowAction extends SerializeResourceAction
|
|||||||
protected $posts;
|
protected $posts;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the serializer class to output results with.
|
* @inheritdoc
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
*/
|
||||||
public static $serializer = 'Flarum\Api\Serializers\DiscussionSerializer';
|
public static $serializer = 'Flarum\Api\Serializers\DiscussionSerializer';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The relationships that are available to be included, and which ones are
|
* @inheritdoc
|
||||||
* included by default.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
*/
|
||||||
public static $include = [
|
public static $include = [
|
||||||
'startUser' => false,
|
'startUser' => false,
|
||||||
@@ -47,23 +42,27 @@ class ShowAction extends SerializeResourceAction
|
|||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The relations that are linked by default.
|
* @inheritdoc
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
*/
|
||||||
public static $link = ['posts', 'posts.discussion'];
|
public static $link = ['posts', 'posts.discussion'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The fields that are available to be sorted by.
|
* @inheritdoc
|
||||||
*
|
*/
|
||||||
* @var array
|
public static $limitMax = 50;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public static $limit = 20;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
public static $sortFields = ['time'];
|
public static $sortFields = ['time'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default sort field and order to user.
|
* @inheritdoc
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
*/
|
||||||
public static $sort = ['time' => 'asc'];
|
public static $sort = ['time' => 'asc'];
|
||||||
|
|
||||||
|
@@ -15,22 +15,43 @@ class UpdateAction extends SerializeResourceAction
|
|||||||
protected $bus;
|
protected $bus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the serializer class to output results with.
|
* @inheritdoc
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
*/
|
||||||
public static $serializer = 'Flarum\Api\Serializers\DiscussionSerializer';
|
public static $serializer = 'Flarum\Api\Serializers\DiscussionSerializer';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The relations that are included by default.
|
* @inheritdoc
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
*/
|
||||||
public static $include = [
|
public static $include = [
|
||||||
'addedPosts' => true,
|
'addedPosts' => true,
|
||||||
'addedPosts.user' => 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.
|
* Instantiate the action.
|
||||||
*
|
*
|
||||||
|
@@ -7,12 +7,40 @@ use Tobscure\JsonApi\Document;
|
|||||||
class ShowAction extends SerializeResourceAction
|
class ShowAction extends SerializeResourceAction
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The name of the serializer class to output results with.
|
* @inheritdoc
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
*/
|
||||||
public static $serializer = 'Flarum\Api\Serializers\ForumSerializer';
|
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
|
* Get the forum, ready to be serialized and assigned to the JsonApi
|
||||||
* response.
|
* response.
|
||||||
|
@@ -8,12 +8,40 @@ use Tobscure\JsonApi\Document;
|
|||||||
class IndexAction extends SerializeCollectionAction
|
class IndexAction extends SerializeCollectionAction
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The name of the serializer class to output results with.
|
* @inheritdoc
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
*/
|
||||||
public static $serializer = 'Flarum\Api\Serializers\GroupSerializer';
|
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
|
* Get the groups, ready to be serialized and assigned to the document
|
||||||
* response.
|
* response.
|
||||||
|
@@ -14,16 +14,12 @@ class IndexAction extends SerializeCollectionAction
|
|||||||
protected $notifications;
|
protected $notifications;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the serializer class to output results with.
|
* @inheritdoc
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
*/
|
||||||
public static $serializer = 'Flarum\Api\Serializers\NotificationSerializer';
|
public static $serializer = 'Flarum\Api\Serializers\NotificationSerializer';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The relations that are included by default.
|
* @inheritdoc
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
*/
|
||||||
public static $include = [
|
public static $include = [
|
||||||
'sender' => true,
|
'sender' => true,
|
||||||
@@ -32,19 +28,30 @@ class IndexAction extends SerializeCollectionAction
|
|||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The maximum number of records that can be requested.
|
* @inheritdoc
|
||||||
*
|
*/
|
||||||
* @var integer
|
public static $link = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
public static $limitMax = 50;
|
public static $limitMax = 50;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of records included by default.
|
* @inheritdoc
|
||||||
*
|
|
||||||
* @var integer
|
|
||||||
*/
|
*/
|
||||||
public static $limit = 10;
|
public static $limit = 10;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public static $sortFields = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public static $sort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiate the action.
|
* Instantiate the action.
|
||||||
*
|
*
|
||||||
|
@@ -14,12 +14,40 @@ class UpdateAction extends SerializeResourceAction
|
|||||||
protected $bus;
|
protected $bus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the serializer class to output results with.
|
* @inheritdoc
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
*/
|
||||||
public static $serializer = 'Flarum\Api\Serializers\NotificationSerializer';
|
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.
|
* Instantiate the action.
|
||||||
*
|
*
|
||||||
|
@@ -14,16 +14,42 @@ class CreateAction extends BaseCreateAction
|
|||||||
protected $bus;
|
protected $bus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the serializer class to output results with.
|
* @inheritdoc
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
*/
|
||||||
public static $serializer = 'Flarum\Api\Serializers\PostSerializer';
|
public static $serializer = 'Flarum\Api\Serializers\PostSerializer';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
public static $include = [
|
public static $include = [
|
||||||
'user' => true
|
'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.
|
* Instantiate the action.
|
||||||
*
|
*
|
||||||
|
@@ -15,17 +15,12 @@ class IndexAction extends SerializeCollectionAction
|
|||||||
protected $posts;
|
protected $posts;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the serializer class to output results with.
|
* @inheritdoc
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
*/
|
||||||
public static $serializer = 'Flarum\Api\Serializers\PostSerializer';
|
public static $serializer = 'Flarum\Api\Serializers\PostSerializer';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The relationships that are available to be included, and which ones are
|
* @inheritdoc
|
||||||
* included by default.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
*/
|
||||||
public static $include = [
|
public static $include = [
|
||||||
'user' => true,
|
'user' => true,
|
||||||
@@ -35,6 +30,31 @@ class IndexAction extends SerializeCollectionAction
|
|||||||
'discussion' => true
|
'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.
|
* Instantiate the action.
|
||||||
*
|
*
|
||||||
|
@@ -14,17 +14,12 @@ class ShowAction extends SerializeResourceAction
|
|||||||
protected $posts;
|
protected $posts;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the serializer class to output results with.
|
* @inheritdoc
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
*/
|
||||||
public static $serializer = 'Flarum\Api\Serializers\PostSerializer';
|
public static $serializer = 'Flarum\Api\Serializers\PostSerializer';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The relationships that are available to be included, and which ones are
|
* @inheritdoc
|
||||||
* included by default.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
*/
|
||||||
public static $include = [
|
public static $include = [
|
||||||
'user' => true,
|
'user' => true,
|
||||||
@@ -34,6 +29,31 @@ class ShowAction extends SerializeResourceAction
|
|||||||
'discussion' => false
|
'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.
|
* Instantiate the action.
|
||||||
*
|
*
|
||||||
|
@@ -14,12 +14,40 @@ class UpdateAction extends SerializeResourceAction
|
|||||||
protected $bus;
|
protected $bus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the serializer class to output results with.
|
* @inheritdoc
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
*/
|
||||||
public static $serializer = 'Flarum\Api\Serializers\PostSerializer';
|
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.
|
* Instantiate the action.
|
||||||
*
|
*
|
||||||
|
@@ -23,12 +23,40 @@ class CreateAction extends BaseCreateAction
|
|||||||
protected $forum;
|
protected $forum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the serializer class to output results with.
|
* @inheritdoc
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
*/
|
||||||
public static $serializer = 'Flarum\Api\Serializers\UserSerializer';
|
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.
|
* Instantiate the action.
|
||||||
*
|
*
|
||||||
|
@@ -14,9 +14,7 @@ class DeleteAvatarAction extends SerializeResourceAction
|
|||||||
protected $bus;
|
protected $bus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the serializer class to output results with.
|
* @inheritdoc
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
*/
|
||||||
public static $serializer = 'Flarum\Api\Serializers\UserSerializer';
|
public static $serializer = 'Flarum\Api\Serializers\UserSerializer';
|
||||||
|
|
||||||
|
@@ -23,6 +23,43 @@ class IndexAction extends SerializeCollectionAction
|
|||||||
*/
|
*/
|
||||||
protected $url;
|
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.
|
* Instantiate the action.
|
||||||
*
|
*
|
||||||
@@ -35,30 +72,6 @@ class IndexAction extends SerializeCollectionAction
|
|||||||
$this->url = $url;
|
$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
|
* Get the user results, ready to be serialized and assigned to the
|
||||||
* document response.
|
* document response.
|
||||||
@@ -77,15 +90,11 @@ class IndexAction extends SerializeCollectionAction
|
|||||||
|
|
||||||
$results = $this->searcher->search($criteria, $request->limit, $request->offset, $request->include);
|
$results = $this->searcher->search($criteria, $request->limit, $request->offset, $request->include);
|
||||||
|
|
||||||
if (($total = $results->getTotal()) !== null) {
|
|
||||||
$document->addMeta('total', $total);
|
|
||||||
}
|
|
||||||
|
|
||||||
static::addPaginationLinks(
|
static::addPaginationLinks(
|
||||||
$document,
|
$document,
|
||||||
$request,
|
$request,
|
||||||
$this->url->toRoute('flarum.api.users.index'),
|
$this->url->toRoute('flarum.api.users.index'),
|
||||||
$total ?: $results->areMoreResults()
|
$results->areMoreResults()
|
||||||
);
|
);
|
||||||
|
|
||||||
return $results->getUsers();
|
return $results->getUsers();
|
||||||
|
@@ -13,24 +13,42 @@ class ShowAction extends SerializeResourceAction
|
|||||||
protected $users;
|
protected $users;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the serializer class to output results with.
|
* @inheritdoc
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
*/
|
||||||
public static $serializer = 'Flarum\Api\Serializers\CurrentUserSerializer';
|
public static $serializer = 'Flarum\Api\Serializers\CurrentUserSerializer';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The relationships that are available to be included, and which ones are
|
* @inheritdoc
|
||||||
* included by default.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
*/
|
||||||
public static $include = [
|
public static $include = [
|
||||||
'groups' => true
|
'groups' => true
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
public static $link = [];
|
public static $link = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public static $limitMax = 50;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public static $limit = 20;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public static $sortFields = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public static $sort;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiate the action.
|
* Instantiate the action.
|
||||||
*
|
*
|
||||||
|
@@ -14,12 +14,40 @@ class UpdateAction extends SerializeResourceAction
|
|||||||
protected $bus;
|
protected $bus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the serializer class to output results with.
|
* @inheritdoc
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
*/
|
||||||
public static $serializer = 'Flarum\Api\Serializers\UserSerializer';
|
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.
|
* Instantiate the action.
|
||||||
*
|
*
|
||||||
|
@@ -14,12 +14,40 @@ class UploadAvatarAction extends SerializeResourceAction
|
|||||||
protected $bus;
|
protected $bus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the serializer class to output results with.
|
* @inheritdoc
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
*/
|
||||||
public static $serializer = 'Flarum\Api\Serializers\UserSerializer';
|
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.
|
* Instantiate the action.
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user