abstract_block
abstract class abstract_block implements block_interface
| internal |
Base class for internal UI Blocks/Widgets.
NOTE: This is NOT a standard Moodle Block (block_base). It is a reusable UI component/driver used by block_middag or middag pages.
This allows the 'local' plugin to drive content dynamically into 'block_middag' without modifying the block plugin itself.
Constants
| TEMPLATE |
The template associated with this block. This constant holds the name the template used to render the output of the block. If empty, a default template might be used. Override in child classes. |
Properties
| protected string | $title | ||
| protected array<string,mixed> | $content | ||
| protected array<string,string> | $attributes |
Methods
Logic to determine and set the block title.
Get the block title, lazily loading it if empty.
Main logic to fetch data for the block.
Retrieves all the content of the block with memoization.
Sets an HTML attribute for the block wrapper.
Renders the widget using the specified template and processed content.
Gets the attributes string safely using Moodle's html_writer.
Details
at line 66
abstract void
set_title()
Logic to determine and set the block title.
Called automatically by get_title() if needed.
at line 73
string
get_title()
Get the block title, lazily loading it if empty.
at line 87
abstract array
process_content()
Main logic to fetch data for the block.
at line 97
array
get_content()
Retrieves all the content of the block with memoization.
Using a boolean flag ($processed) is safer than checking for empty array, as the content might legitimately be empty after processing.
at line 113
void
set_attribute(string $key, string $value)
Sets an HTML attribute for the block wrapper.
at line 123
string
render()
Renders the widget using the specified template and processed content.
at line 153
protected string
get_attributes()
Gets the attributes string safely using Moodle's html_writer.
This handles escaping and boolean attributes correctly.