Documentation

BookApiHandler
in package
implements ApiRoutableInterface uses ApiRoutableTrait

API handler for book operations.

Handles REST API endpoints for book management.

Tags
since
3.0.0

Table of Contents

Interfaces

ApiRoutableInterface
Interface for API handlers that participate in route dispatch.

Properties

$bookFacade  : BookFacade

Methods

__construct()  : mixed
Constructor.
deleteBook()  : array<string|int, mixed>
Handle DELETE /api/v1/books/{id} request.
getBook()  : array<string|int, mixed>
Handle GET /api/v1/books/{id} request.
getChapters()  : array<string|int, mixed>
Handle GET /api/v1/books/{id}/chapters request.
importBook()  : array<string|int, mixed>
Handle POST /api/v1/books request — import an EPUB upload.
listBooks()  : array<string|int, mixed>
Handle GET /api/v1/books request.
routeDelete()  : JsonResponse
Handle a DELETE request for this resource.
routeGet()  : JsonResponse
Handle a GET request for this resource.
routePost()  : JsonResponse
Handle a POST request for this resource.
routePut()  : JsonResponse
Handle a PUT request for this resource.
updateProgress()  : array<string|int, mixed>
Handle PUT /api/v1/books/{id}/progress request.
frag()  : string
Extract a fragment from the fragments array.
parseTagIds()  : array<string|int, int>
Normalise the posted tag selection into a list of tag IDs.

Properties

Methods

deleteBook()

Handle DELETE /api/v1/books/{id} request.

public deleteBook(array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
$params : array<string|int, mixed>

Request parameters (id)

Return values
array<string|int, mixed>

Response data

getBook()

Handle GET /api/v1/books/{id} request.

public getBook(array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
$params : array<string|int, mixed>

Request parameters (id)

Return values
array<string|int, mixed>

Response data

getChapters()

Handle GET /api/v1/books/{id}/chapters request.

public getChapters(array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
$params : array<string|int, mixed>

Request parameters (id)

Return values
array<string|int, mixed>

Response data

importBook()

Handle POST /api/v1/books request — import an EPUB upload.

public importBook(array<string|int, mixed> $params) : array<string|int, mixed>

The upload arrives as multipart/form-data, so the file itself comes from $_FILES rather than the decoded body. Both field-name pairs the old /book/import form used are accepted so either caller can post here.

Parameters
$params : array<string|int, mixed>

Request parameters (LgID or TxLgID, TxTitle, TextTags)

Return values
array<string|int, mixed>

Response data

listBooks()

Handle GET /api/v1/books request.

public listBooks(array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
$params : array<string|int, mixed>

Request parameters

Return values
array<string|int, mixed>

Response data

routeDelete()

Handle a DELETE request for this resource.

public routeDelete(array<string|int, mixed> $fragments, array<string|int, mixed> $params) : JsonResponse
Parameters
$fragments : array<string|int, mixed>

URL path segments (resource name already consumed)

$params : array<string|int, mixed>

Query/body parameters

Return values
JsonResponse

routeGet()

Handle a GET request for this resource.

public routeGet(array<string|int, mixed> $fragments, array<string|int, mixed> $params) : JsonResponse
Parameters
$fragments : array<string|int, mixed>

URL path segments (resource name already consumed)

$params : array<string|int, mixed>

Query parameters

Return values
JsonResponse

routePost()

Handle a POST request for this resource.

public routePost(array<string|int, mixed> $fragments, array<string|int, mixed> $params) : JsonResponse
Parameters
$fragments : array<string|int, mixed>

URL path segments (resource name already consumed)

$params : array<string|int, mixed>

POST/JSON body parameters

Return values
JsonResponse

routePut()

Handle a PUT request for this resource.

public routePut(array<string|int, mixed> $fragments, array<string|int, mixed> $params) : JsonResponse
Parameters
$fragments : array<string|int, mixed>

URL path segments (resource name already consumed)

$params : array<string|int, mixed>

JSON body parameters

Return values
JsonResponse

updateProgress()

Handle PUT /api/v1/books/{id}/progress request.

public updateProgress(array<string|int, mixed> $params) : array<string|int, mixed>

Update reading progress for a book.

Parameters
$params : array<string|int, mixed>

Request parameters (id, chapter)

Return values
array<string|int, mixed>

Response data

frag()

Extract a fragment from the fragments array.

protected frag(array<int, string> $fragments, int $index) : string
Parameters
$fragments : array<int, string>

The URL path fragments

$index : int

The index to extract

Return values
string

The fragment at the index, or empty string if not present

parseTagIds()

Normalise the posted tag selection into a list of tag IDs.

private parseTagIds(mixed $raw) : array<string|int, int>

The field arrives in two shapes: a comma-separated string when the form is posted as-is, and an array once Tagify has replaced the input with its own multi-value control. Casting an array to string is a warning that the exception handler turns into a 500, so both are handled here.

Parameters
$raw : mixed

Posted TextTags value

Return values
array<string|int, int>

Tag IDs, without zeroes

On this page

Search results