MIDDAG for Moodle

shortcode_manager_interface

Interface for the Shortcode Manager.

Defines the contract for registering and rendering [middag] shortcodes.

Table of Contents

Methods

clear()  : void
Clears all registered shortcodes.
has()  : bool
Checks whether a shortcode is registered.
register()  : void
Registers a shortcode by associating a tag with a callback function.
render()  : string
Processes the given text, parses shortcode patterns, and replaces them with corresponding content.

Methods

has()

Checks whether a shortcode is registered.

public has(string $tag) : bool
Parameters
$tag : string

the shortcode tag name to check

Return values
bool

true if the shortcode is registered; false otherwise

register()

Registers a shortcode by associating a tag with a callback function.

public register(string $tag, callable $callback) : void
Parameters
$tag : string

the name of the shortcode tag to register (case-insensitive)

$callback : callable

the callback function that renders the content for the shortcode

render()

Processes the given text, parses shortcode patterns, and replaces them with corresponding content.

public render(string $text) : string
Parameters
$text : string

the input text containing shortcodes to be rendered

Return values
string

the text with shortcodes replaced by their respective rendered content


        
On this page

Search results