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
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
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
$crud
private
TagCrudApiHandler
$crud
Methods
__construct()
public
__construct([TagCrudApiHandler|null $crud = null ]) : mixed
Parameters
- $crud : TagCrudApiHandler|null = null
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
JsonResponsehandleGet()
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
JsonResponserouteDelete()
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
JsonResponserouteGet()
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
JsonResponseroutePost()
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
JsonResponseroutePut()
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
JsonResponsefrag()
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