Documentation

TagApiHandler
in package
implements ApiRoutableInterface uses ApiRoutableTrait

API handler for tag endpoints.

Handles:

  • GET /api/v1/tags - Get all tags (both term and text)
  • GET /api/v1/tags/{type} - Flat name list for autocomplete
  • GET /api/v1/tags/{type}/list - Paginated records for the tag pages
  • GET /api/v1/tags/{type}/{id} - One tag
  • POST /api/v1/tags/{type} - Create
  • PUT /api/v1/tags/{type}/{id} - Update
  • DELETE /api/v1/tags/{type}/{id} - Delete one
  • DELETE /api/v1/tags/{type} - Delete selected, or all matching

{type} is term or text. The flat list and the paginated list are deliberately different routes: Tagify and the term editor consume the flat one and would break if it grew an envelope.

Tags
since
3.0.0

Table of Contents

Interfaces

ApiRoutableInterface
Interface for API handlers that participate in route dispatch.

Constants

TAG_TYPES  : mixed = ['term', 'text']
Tag collections the CRUD routes address.

Properties

$crud  : TagCrudApiHandler

Methods

__construct()  : mixed
handle()  : JsonResponse
Handle request routing.
handleGet()  : JsonResponse
Handle GET request for tags.
routeDelete()  : JsonResponse
Route a DELETE request.
routeGet()  : JsonResponse
Route a GET request to the appropriate handler.
routePost()  : JsonResponse
Route a POST request.
routePut()  : JsonResponse
Route a PUT request.
frag()  : string
Extract a fragment from the fragments array.

Constants

TAG_TYPES

Tag collections the CRUD routes address.

private mixed TAG_TYPES = ['term', 'text']

Properties

Methods

handle()

Handle request routing.

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

HTTP method

$fragments : array<string|int, mixed>

URL fragments

Return values
JsonResponse

handleGet()

Handle GET request for tags.

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

URL path fragments after /tags

Return values
JsonResponse

routeDelete()

Route a DELETE request.

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

URL path fragments

$params : array<string, mixed>

Request body

Return values
JsonResponse

routeGet()

Route a GET request to the appropriate handler.

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

URL path fragments

$params : array<string, mixed>

Query parameters

Return values
JsonResponse

routePost()

Route a POST request.

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

URL path fragments

$params : array<string, mixed>

Request body

Return values
JsonResponse

routePut()

Route a PUT request.

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

URL path fragments

$params : array<string, mixed>

Request body

Return values
JsonResponse

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

On this page

Search results