class ApiController implements ExtenderInterface

Methods

__construct(string $controllerClass)

No description

prepareDataQuery(callable|string $callback)

No description

prepareDataForSerialization(callable|string $callback)

No description

setSerializer(string $serializerClass, callable|string|null $callback = null)

Set the serializer that will serialize data for the endpoint.

addInclude(string|array $name, callable|string|null $callback = null)

Include the given relationship by default.

removeInclude(string|array $name, callable|string|null $callback = null)

Don't include the given relationship by default.

addOptionalInclude(string|array $name, callable|string|null $callback = null)

Make the given relationship available for inclusion.

removeOptionalInclude(string|array $name, callable|string|null $callback = null)

Don't allow the given relationship to be included.

setLimit(int $limit, callable|string|null $callback = null)

Set the default number of results.

setMaxLimit(int $max, callable|string|null $callback = null)

Set the maximum number of results.

addSortField(string|array $field, callable|string|null $callback = null)

Allow sorting results by the given field.

removeSortField(string|array $field, callable|string|null $callback = null)

Disallow sorting results by the given field.

setSort(array $sort, callable|string|null $callback = null)

Set the default sort order for the results.

extend(Container $container, Extension $extension = null)

No description

Details

__construct(string $controllerClass)

Parameters

string $controllerClass The ::class attribute of the controller you are modifying. This controller should extend from \Flarum\Api\Controller\AbstractSerializeController.

ApiController prepareDataQuery(callable|string $callback)

Parameters

callable|string $callback The callback can be a closure or an invokable class, and should accept: - $controller: An instance of this controller.

Return Value

ApiController

ApiController prepareDataForSerialization(callable|string $callback)

Parameters

callable|string $callback The callback can be a closure or an invokable class, and should accept: - $controller: An instance of this controller. - $data: Mixed, can be an array of data or an object (like an instance of Collection or AbstractModel). - $request: An instance of \Psr\Http\Message\ServerRequestInterface. - $document: An instance of \Tobscure\JsonApi\Document.</p> <p>The callable should return: - An array of additional data to merge with the existing array. Or a modified $data array.

Return Value

ApiController

ApiController setSerializer(string $serializerClass, callable|string|null $callback = null)

Set the serializer that will serialize data for the endpoint.

Parameters

string $serializerClass
callable|string|null $callback

Return Value

ApiController

ApiController addInclude(string|array $name, callable|string|null $callback = null)

Include the given relationship by default.

Parameters

string|array $name
callable|string|null $callback

Return Value

ApiController

ApiController removeInclude(string|array $name, callable|string|null $callback = null)

Don't include the given relationship by default.

Parameters

string|array $name
callable|string|null $callback

Return Value

ApiController

ApiController addOptionalInclude(string|array $name, callable|string|null $callback = null)

Make the given relationship available for inclusion.

Parameters

string|array $name
callable|string|null $callback

Return Value

ApiController

ApiController removeOptionalInclude(string|array $name, callable|string|null $callback = null)

Don't allow the given relationship to be included.

Parameters

string|array $name
callable|string|null $callback

Return Value

ApiController

ApiController setLimit(int $limit, callable|string|null $callback = null)

Set the default number of results.

Parameters

int $limit
callable|string|null $callback

Return Value

ApiController

ApiController setMaxLimit(int $max, callable|string|null $callback = null)

Set the maximum number of results.

Parameters

int $max
callable|string|null $callback

Return Value

ApiController

ApiController addSortField(string|array $field, callable|string|null $callback = null)

Allow sorting results by the given field.

Parameters

string|array $field
callable|string|null $callback

Return Value

ApiController

ApiController removeSortField(string|array $field, callable|string|null $callback = null)

Disallow sorting results by the given field.

Parameters

string|array $field
callable|string|null $callback

Return Value

ApiController

ApiController setSort(array $sort, callable|string|null $callback = null)

Set the default sort order for the results.

Parameters

array $sort
callable|string|null $callback

Return Value

ApiController

extend(Container $container, Extension $extension = null)

Parameters

Container $container
Extension $extension