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)

<p>Set the serializer that will serialize data for the endpoint.</p>

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

<p>Include the given relationship by default.</p>

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

<p>Don't include the given relationship by default.</p>

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

<p>Make the given relationship available for inclusion.</p>

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

<p>Don't allow the given relationship to be included.</p>

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

<p>Set the default number of results.</p>

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

<p>Set the maximum number of results.</p>

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

<p>Allow sorting results by the given field.</p>

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

<p>Disallow sorting results by the given field.</p>

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

<p>Set the default sort order for the results.</p>

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

No description

Details

__construct(string $controllerClass)

Parameters

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

ApiController prepareDataQuery(callable|string $callback)

Parameters

callable|string $callback <p>The callback can be a closure or an invokable class, and should accept:</p> <ul> <li>$controller: An instance of this controller.</li> </ul>

Return Value

ApiController

ApiController prepareDataForSerialization(callable|string $callback)

Parameters

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

Return Value

ApiController

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

<p>Set the serializer that will serialize data for the endpoint.</p>

Parameters

string $serializerClass
callable|string|null $callback

Return Value

ApiController

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

<p>Include the given relationship by default.</p>

Parameters

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

Return Value

ApiController

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

<p>Don't include the given relationship by default.</p>

Parameters

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

Return Value

ApiController

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

<p>Make the given relationship available for inclusion.</p>

Parameters

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

Return Value

ApiController

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

<p>Don't allow the given relationship to be included.</p>

Parameters

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

Return Value

ApiController

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

<p>Set the default number of results.</p>

Parameters

int $limit
callable|string|null $callback

Return Value

ApiController

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

<p>Set the maximum number of results.</p>

Parameters

int $max
callable|string|null $callback

Return Value

ApiController

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

<p>Allow sorting results by the given field.</p>

Parameters

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

Return Value

ApiController

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

<p>Disallow sorting results by the given field.</p>

Parameters

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

Return Value

ApiController

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

<p>Set the default sort order for the results.</p>

Parameters

array $sort
callable|string|null $callback

Return Value

ApiController

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

Parameters

Container $container
Extension $extension