mirror of
https://github.com/flarum/core.git
synced 2025-10-13 16:05:05 +02:00
Convert the rest of the API to new action architecture
Also make some tweaks: - Merge SerializeAction::$include and SerializeAction::$includeAvailable into a keyed boolean array - Set defaults for SerializeAction::$limit and $limitMax - Rename SerializeAction::$sortAvailable to $sortFields
This commit is contained in:
@@ -23,46 +23,25 @@ class IndexAction extends SerializeCollectionAction
|
||||
public static $serializer = 'Flarum\Api\Serializers\DiscussionSerializer';
|
||||
|
||||
/**
|
||||
* The relations that are available to be included.
|
||||
* The relationships that are available to be included, and which ones are
|
||||
* included by default.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $includeAvailable = ['startUser', 'lastUser', 'startPost', 'lastPost', 'relevantPosts'];
|
||||
|
||||
/**
|
||||
* The relations that are included by default.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $include = ['startUser', 'lastUser'];
|
||||
|
||||
/**
|
||||
* The maximum number of records that can be requested.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public static $limitMax = 50;
|
||||
|
||||
/**
|
||||
* The number of records included by default.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public static $limit = 20;
|
||||
public static $include = [
|
||||
'startUser' => true,
|
||||
'lastUser' => true,
|
||||
'startPost' => false,
|
||||
'lastPost' => false,
|
||||
'relevantPosts' => false
|
||||
];
|
||||
|
||||
/**
|
||||
* The fields that are available to be sorted by.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $sortAvailable = ['lastTime', 'commentsCount', 'startTime'];
|
||||
|
||||
/**
|
||||
* The default field to sort by.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $sort = ['lastTime' => 'desc'];
|
||||
public static $sortFields = ['lastTime', 'commentsCount', 'startTime'];
|
||||
|
||||
/**
|
||||
* Instantiate the action.
|
||||
|
Reference in New Issue
Block a user