class ApiResource implements ExtenderInterface

Methods

__construct(string $resourceClass)

No description

endpoints(callable|string $endpoints)

Add endpoints to the resource.

endpointsBefore(string $before, callable|string $endpoints)

Add endpoints to the resource before a certain endpoint.

endpointsAfter(string $after, callable|string $endpoints)

Add endpoints to the resource after a certain endpoint.

endpointsBeforeAll(callable|string $endpoints)

Add endpoints to the resource before all other endpoints.

removeEndpoints(array $endpoints, callable|string|null $condition = null)

Remove endpoints from the resource.

endpoint(string|array $endpointNameOrClass, callable|string $mutator)

Modify an endpoint.

fields(callable|string $fields)

Add fields to the resource.

fieldsBefore(string $before, callable|string $fields)

Add fields to the resource before a certain field.

fieldsAfter(string $after, callable|string $fields)

Add fields to the resource after a certain field.

removeFields(array $fields, callable|string|null $condition = null)

Remove fields from the resource.

field(string|array $field, callable|string $mutator)

Modify a field.

sorts(callable|string $sorts)

Add sorts to the resource.

removeSorts(array $sorts, callable|string|null $condition = null)

Remove sorts from the resource.

sort(string|array $sort, callable|string $mutator)

Modify a sort.

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

No description

Details

__construct(string $resourceClass)

Parameters

string $resourceClass

ApiResource endpoints(callable|string $endpoints)

Add endpoints to the resource.

Parameters

callable|string $endpoints must be a callable that returns an array of objects that implement \Flarum\Api\Endpoint\Endpoint.

Return Value

ApiResource

ApiResource endpointsBefore(string $before, callable|string $endpoints)

Add endpoints to the resource before a certain endpoint.

Parameters

string $before the name of the endpoint to add the new endpoints before.
callable|string $endpoints must be a callable that returns an array of objects that implement \Flarum\Api\Endpoint\Endpoint.

Return Value

ApiResource

ApiResource endpointsAfter(string $after, callable|string $endpoints)

Add endpoints to the resource after a certain endpoint.

Parameters

string $after the name of the endpoint to add the new endpoints after.
callable|string $endpoints must be a callable that returns an array of objects that implement \Flarum\Api\Endpoint\Endpoint.

Return Value

ApiResource

ApiResource endpointsBeforeAll(callable|string $endpoints)

Add endpoints to the resource before all other endpoints.

Parameters

callable|string $endpoints must be a callable that returns an array of objects that implement \Flarum\Api\Endpoint\Endpoint.

Return Value

ApiResource

ApiResource removeEndpoints(array $endpoints, callable|string|null $condition = null)

Remove endpoints from the resource.

Parameters

array $endpoints must be an array of names of the endpoints.
callable|string|null $condition a callable that returns a boolean or a string that represents whether this should be applied.

Return Value

ApiResource

ApiResource endpoint(string|array $endpointNameOrClass, callable|string $mutator)

Modify an endpoint.

Parameters

string|array $endpointNameOrClass the name or class name of the endpoint or an array of so.
callable|string $mutator a callable that accepts an endpoint and returns the modified endpoint.

Return Value

ApiResource

ApiResource fields(callable|string $fields)

Add fields to the resource.

Parameters

callable|string $fields must be a callable that returns an array of objects that implement \Tobyz\JsonApiServer\Schema\Field.

Return Value

ApiResource

ApiResource fieldsBefore(string $before, callable|string $fields)

Add fields to the resource before a certain field.

Parameters

string $before the name of the field to add the new fields before.
callable|string $fields must be a callable that returns an array of objects that implement \Tobyz\JsonApiServer\Schema\Field.

Return Value

ApiResource

ApiResource fieldsAfter(string $after, callable|string $fields)

Add fields to the resource after a certain field.

Parameters

string $after the name of the field to add the new fields after.
callable|string $fields must be a callable that returns an array of objects that implement \Tobyz\JsonApiServer\Schema\Field.

Return Value

ApiResource

ApiResource removeFields(array $fields, callable|string|null $condition = null)

Remove fields from the resource.

Parameters

array $fields must be an array of field names.
callable|string|null $condition a callable that returns a boolean or a string that represents whether this should be applied.

Return Value

ApiResource

ApiResource field(string|array $field, callable|string $mutator)

Modify a field.

Parameters

string|array $field the name of the field or an array of field names.
callable|string $mutator a callable that accepts a field and returns the modified field.

Return Value

ApiResource

ApiResource sorts(callable|string $sorts)

Add sorts to the resource.

Parameters

callable|string $sorts must be a callable that returns an array of objects that implement \Tobyz\JsonApiServer\Schema\Sort.

Return Value

ApiResource

ApiResource removeSorts(array $sorts, callable|string|null $condition = null)

Remove sorts from the resource.

Parameters

array $sorts must be an array of sort names.
callable|string|null $condition a callable that returns a boolean or a string that represents whether this should be applied.

Return Value

ApiResource

ApiResource sort(string|array $sort, callable|string $mutator)

Modify a sort.

Parameters

string|array $sort the name of the sort or an array of sort names.
callable|string $mutator a callable that accepts a sort and returns the modified sort.

Return Value

ApiResource

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

Parameters

Container $container
Extension|null $extension

Return Value

void