widget_interface
Contract for UI widgets.
Widgets prepare data for a frontend component (Mustache or Vue) and expose rendering helpers used by controllers and blocks.
Table of Contents
Methods
- get_data() : array<string, mixed>
- Prepare and return the data structure required by the template/component.
- get_id() : string
- Get the unique identifier.
- render() : string
- Render the widget's HTML output.
- set_id() : void
- Set the unique identifier for this widget instance.
Methods
get_data()
Prepare and return the data structure required by the template/component.
public
get_data() : array<string, mixed>
Return values
array<string, mixed>get_id()
Get the unique identifier.
public
get_id() : string
Return values
stringrender()
Render the widget's HTML output.
public
render() : string
Usually delegates to $OUTPUT->render_from_template().
Return values
string —HTML
set_id()
Set the unique identifier for this widget instance.
public
set_id(string $id) : void
Needed for DOM ID generation and Vue mounting points.
Parameters
- $id : string