Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
core_reportbuilder\local\report\action Class Reference

Public Member Functions

 __construct (moodle_url $url, pix_icon $icon, array $attributes=[], bool $popup=false, ?lang_string $title=null)
 Create an instance of an action to be added to a report.
 
 add_callback (callable $callback)
 Adds callback to the action.
 
 get_action_link (stdClass $row)
 Return action menu link suitable for output, or null if the action cannot be displayed (because one of its callbacks returned false, {.
 

Protected Attributes

array $attributes
 $attributes
 
callable[] $callbacks = []
 $callbacks
 
pix_icon $icon
 $icon
 
bool $popup
 $popup
 
lang_string string $title
 $title
 
moodle_url $url
 $url
 

Constructor & Destructor Documentation

◆ __construct()

core_reportbuilder\local\report\action::__construct ( moodle_url $url,
pix_icon $icon,
array $attributes = [],
bool $popup = false,
?lang_string $title = null )

Create an instance of an action to be added to a report.

Both the parameters of the URL, and the attributes parameter support placeholders which will be replaced with appropriate row values, e.g.:

new action(new moodle_url('/', ['id' => ':id']), new pix_icon(...), ['data-id' => ':id'])

Note that all expected placeholders should be added as base fields to the report

Parameters
moodle_url$url
pix_icon$icon
string[]$attributesArray of attributes to include in action, each will be cast to string prior to use
bool$popup
?lang_string$title

Member Function Documentation

◆ add_callback()

core_reportbuilder\local\report\action::add_callback ( callable $callback)

Adds callback to the action.

Used to verify action is available to current user, or preprocess values used in placeholders

Multiple callbacks can be added. If at least one returns false then the action will not be displayed

Parameters
callable$callback
Return values
self

◆ get_action_link()

core_reportbuilder\local\report\action::get_action_link ( stdClass $row)

Return action menu link suitable for output, or null if the action cannot be displayed (because one of its callbacks returned false, {.

See also
add_callback})
Parameters
stdClass$row
Return values
action_menu_link|null

The documentation for this class was generated from the following file: