TermTagController
extends AbstractCrudController
in package
Controller for managing term tags (tags applied to vocabulary words).
Tags
Table of Contents
Properties
- $pageTitle : string
- Page title for the resource index page.
- $resourceName : string
- Singular name of the resource (for messages).
- $showMenu : bool
- Whether to show the navigation menu.
- $currentPage : int
- $currentQuery : string
- $currentSort : int
- $facade : TagsFacade
Methods
- __construct() : mixed
- Constructor.
- delete() : void
- Delete a term tag.
- edit() : void
- Edit term tag form.
- index() : void
- Main index action.
- new() : void
- Show new term tag form.
- dispatchView() : void
- Dispatch to the appropriate view based on request parameters.
- endRender() : void
- End page rendering with standard LWT footer.
- errorMessage() : string
- Display an error message.
- execute() : int
- Execute an INSERT/UPDATE/DELETE query.
- formatBulkActionMessage() : string
- Format bulk action result into a display message.
- get() : string
- Get a string GET parameter.
- getCurrentPage() : int
- Get current page number from request.
- getCurrentQuery() : string
- Get current search query from request.
- getCurrentSort() : int
- Get current sort order from request/database.
- getIdParameterName() : string
- Get the ID parameter name.
- getMarkedIds() : array<string|int, int>
- Get IDs from marked checkboxes.
- getValue() : mixed
- Get a single value from the database.
- handleBulkAction() : array{action: string, count: int, error?: string, success: bool}
- Handle bulk action.
- handleBulkDelete() : array{success: bool, count: int, action: string}
- Handle bulk delete operation.
- handleCreate() : string
- Handle create operation.
- handleDelete() : string
- Handle delete operation.
- handleUpdate() : string
- Handle update operation.
- hasParam() : bool
- Check if a parameter exists in the request.
- isGet() : bool
- Check if the request is a GET request.
- isPost() : bool
- Check if the request is a POST request.
- json() : JsonResponse
- Return JSON response.
- message() : void
- Display a message (success/error) to the user using Bulma notifications.
- param() : string
- Get a string request parameter (GET, POST, or REQUEST).
- paramArray() : array<string|int, mixed>
- Get an array request parameter.
- paramInt() : int|null
- Get an integer request parameter.
- post() : string
- Get a string POST parameter.
- processActions() : string
- Process CRUD actions from request parameters.
- processAllAction() : array{action: string, count: int, error?: string, success: bool}
- Process action on all filtered items.
- processBulkAction() : array{success: bool, count: int, action: string, error?: string}
- Process bulk action on marked items.
- query() : mysqli_result|bool
- Execute a database query using the LWT query wrapper.
- redirect() : RedirectResponse
- Redirect to another URL.
- render() : void
- Start page rendering with standard LWT header.
- renderCreateForm() : void
- Render the create form.
- renderEditForm() : void
- Render the edit form.
- renderList() : void
- Render the list view.
- requireInt() : int
- Get a required integer request parameter.
- successMessage() : string
- Display a success message.
Properties
$pageTitle
Page title for the resource index page.
protected
string
$pageTitle
= 'Term Tags'
$resourceName
Singular name of the resource (for messages).
protected
string
$resourceName
= 'tag'
$showMenu
Whether to show the navigation menu.
protected
bool
$showMenu
= true
$currentPage
private
int
$currentPage
= 1
$currentQuery
private
string
$currentQuery
= ''
$currentSort
private
int
$currentSort
= 1
$facade
private
TagsFacade
$facade
Methods
__construct()
Constructor.
public
__construct([TagsFacade|null $facade = null ]) : mixed
Parameters
- $facade : TagsFacade|null = null
-
Tags facade
delete()
Delete a term tag.
public
delete(int $id) : void
Route: DELETE /tags/{id}
Parameters
- $id : int
-
Tag ID from route parameter
edit()
Edit term tag form.
public
edit(int $id) : void
Route: GET/POST /tags/{id}/edit
Parameters
- $id : int
-
Tag ID from route parameter
index()
Main index action.
public
index(array<string|int, mixed> $params) : void
Parameters
- $params : array<string|int, mixed>
-
Route parameters
new()
Show new term tag form.
public
new(array<string|int, mixed> $params) : void
Route: GET /tags/new
Parameters
- $params : array<string|int, mixed>
-
Route parameters
dispatchView()
Dispatch to the appropriate view based on request parameters.
protected
dispatchView(string $message) : void
Note: Edit forms are now handled via RESTful /{resource}/{id}/edit routes.
Parameters
- $message : string
-
Message from processed action
endRender()
End page rendering with standard LWT footer.
protected
endRender() : void
errorMessage()
Display an error message.
protected
errorMessage(string $error) : string
Parameters
- $error : string
-
Error description
Return values
string —Formatted error message
execute()
Execute an INSERT/UPDATE/DELETE query.
protected
execute(string $sql) : int
Parameters
- $sql : string
-
SQL query
Tags
Return values
int —Number of affected rows
formatBulkActionMessage()
Format bulk action result into a display message.
protected
formatBulkActionMessage(array{success: bool, count: int, action: string, error?: string} $result) : string
Parameters
- $result : array{success: bool, count: int, action: string, error?: string}
-
Bulk action result
Return values
string —Formatted message for display
get()
Get a string GET parameter.
protected
get(string $key[, string $default = '' ]) : string
Parameters
- $key : string
-
Parameter name
- $default : string = ''
-
Default value if not set
Return values
string —Parameter value or default
getCurrentPage()
Get current page number from request.
protected
getCurrentPage([string $requestKey = 'page' ][, string $sessionKey = 'currentpage' ][, int $default = 1 ]) : int
Parameters
- $requestKey : string = 'page'
-
Request parameter name
- $sessionKey : string = 'currentpage'
-
Unused, kept for BC (was session key)
- $default : int = 1
-
Default page number
Return values
int —Current page number
getCurrentQuery()
Get current search query from request.
protected
getCurrentQuery([string $requestKey = 'query' ][, string $sessionKey = 'currentquery' ][, string $default = '' ]) : string
Parameters
- $requestKey : string = 'query'
-
Request parameter name
- $sessionKey : string = 'currentquery'
-
Unused, kept for BC (was session key)
- $default : string = ''
-
Default query
Return values
string —Current search query
getCurrentSort()
Get current sort order from request/database.
protected
getCurrentSort([string $requestKey = 'sort' ][, string $dbKey = 'currentsort' ][, int $default = 1 ]) : int
Parameters
- $requestKey : string = 'sort'
-
Request parameter name
- $dbKey : string = 'currentsort'
-
Database setting key for persistence
- $default : int = 1
-
Default sort order
Return values
int —Current sort order
getIdParameterName()
Get the ID parameter name.
protected
getIdParameterName() : string
Return values
stringgetMarkedIds()
Get IDs from marked checkboxes.
protected
getMarkedIds(string|array<string|int, mixed> $marked) : array<string|int, int>
Parameters
- $marked : string|array<string|int, mixed>
-
The 'marked' request parameter value
Tags
Return values
array<string|int, int> —Array of integer IDs
getValue()
Get a single value from the database.
protected
getValue(string $sql) : mixed
Parameters
- $sql : string
-
SQL query (should return single value as 'value')
Return values
mixed —The value or null
handleBulkAction()
Handle bulk action.
protected
handleBulkAction(string $action, array<string|int, int> $ids) : array{action: string, count: int, error?: string, success: bool}
Parameters
- $action : string
-
Action code
- $ids : array<string|int, int>
-
Tag IDs
Return values
array{action: string, count: int, error?: string, success: bool}handleBulkDelete()
Handle bulk delete operation.
protected
handleBulkDelete(array<string|int, int> $ids) : array{success: bool, count: int, action: string}
Override this method to implement bulk delete with proper cleanup.
Parameters
- $ids : array<string|int, int>
-
Array of record IDs to delete
Return values
array{success: bool, count: int, action: string} —Result data
handleCreate()
Handle create operation.
protected
handleCreate() : string
Return values
string —Result message
handleDelete()
Handle delete operation.
protected
handleDelete(int $id) : string
Parameters
- $id : int
-
Tag ID
Return values
string —Result message
handleUpdate()
Handle update operation.
protected
handleUpdate(int $id) : string
Parameters
- $id : int
-
Tag ID
Return values
string —Result message
hasParam()
Check if a parameter exists in the request.
protected
hasParam(string $key) : bool
Parameters
- $key : string
-
Parameter name
Return values
bool —True if the parameter exists
isGet()
Check if the request is a GET request.
protected
isGet() : bool
Return values
boolisPost()
Check if the request is a POST request.
protected
isPost() : bool
Return values
booljson()
Return JSON response.
protected
json(mixed $data[, int $status = 200 ]) : JsonResponse
Return this from a controller method; the router will send it.
Parameters
- $data : mixed
-
Data to encode as JSON
- $status : int = 200
-
HTTP status code (default: 200)
Return values
JsonResponsemessage()
Display a message (success/error) to the user using Bulma notifications.
protected
message(string $message[, bool $autoHide = true ]) : void
Parameters
- $message : string
-
The message to display
- $autoHide : bool = true
-
Whether to auto-hide the message (default: true)
param()
Get a string request parameter (GET, POST, or REQUEST).
protected
param(string $key[, string $default = '' ]) : string
Parameters
- $key : string
-
Parameter name
- $default : string = ''
-
Default value if not set
Return values
string —Parameter value or default
paramArray()
Get an array request parameter.
protected
paramArray(string $key[, array<string|int, mixed> $default = [] ]) : array<string|int, mixed>
Parameters
- $key : string
-
Parameter name
- $default : array<string|int, mixed> = []
-
Default value if not set
Return values
array<string|int, mixed> —Parameter value or default
paramInt()
Get an integer request parameter.
protected
paramInt(string $key[, int|null $default = null ][, int|null $min = null ][, int|null $max = null ]) : int|null
Parameters
- $key : string
-
Parameter name
- $default : int|null = null
-
Default value if not set
- $min : int|null = null
-
Minimum allowed value
- $max : int|null = null
-
Maximum allowed value
Return values
int|null —Parameter value or default
post()
Get a string POST parameter.
protected
post(string $key[, string $default = '' ]) : string
Parameters
- $key : string
-
Parameter name
- $default : string = ''
-
Default value if not set
Return values
string —Parameter value or default
processActions()
Process CRUD actions from request parameters.
protected
processActions() : string
Handles the standard action flow:
- Bulk actions (markaction, allaction)
- Create/Update (op parameter)
Note: Single delete is handled via RESTful DELETE routes.
Return values
string —Result message from the action
processAllAction()
Process action on all filtered items.
protected
processAllAction(string $action) : array{action: string, count: int, error?: string, success: bool}
Parameters
- $action : string
-
Action code
Return values
array{action: string, count: int, error?: string, success: bool}processBulkAction()
Process bulk action on marked items.
protected
processBulkAction(string $action) : array{success: bool, count: int, action: string, error?: string}
Override this method to handle bulk operations like bulk delete, bulk status change, etc.
Parameters
- $action : string
-
The action code (e.g., 'del', 'export')
Return values
array{success: bool, count: int, action: string, error?: string} —Result data
query()
Execute a database query using the LWT query wrapper.
protected
query(string $sql) : mysqli_result|bool
Parameters
- $sql : string
-
SQL query
Return values
mysqli_result|bool —Query result
redirect()
Redirect to another URL.
protected
redirect(string $url[, int $statusCode = 302 ]) : RedirectResponse
Return this from a controller method; the router will send it.
Parameters
- $url : string
-
URL to redirect to
- $statusCode : int = 302
-
HTTP status code (default: 302)
Return values
RedirectResponserender()
Start page rendering with standard LWT header.
protected
render(string $title[, bool $showMenu = true ]) : void
Parameters
- $title : string
-
Page title
- $showMenu : bool = true
-
Whether to show navigation menu (default: true)
renderCreateForm()
Render the create form.
protected
renderCreateForm() : void
Tags
renderEditForm()
Render the edit form.
protected
renderEditForm(int $id) : void
Parameters
- $id : int
-
Tag ID
Tags
renderList()
Render the list view.
protected
renderList(string $message) : void
Parameters
- $message : string
-
Message to display
Tags
requireInt()
Get a required integer request parameter.
protected
requireInt(string $key[, int|null $min = null ][, int|null $max = null ]) : int
Parameters
- $key : string
-
Parameter name
- $min : int|null = null
-
Minimum allowed value
- $max : int|null = null
-
Maximum allowed value
Tags
Return values
int —Parameter value
successMessage()
Display a success message.
protected
successMessage(string $action) : string
Parameters
- $action : string
-
Action that was performed (e.g., "Created", "Updated")
Return values
string —Formatted message