Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

(no description)

File Size: 154 lines (5 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

action:: (4 methods):
  __construct()
  add_callback()
  get_action_link()
  replace_placeholders()


Class: action  - X-Ref

Class to represent a report action

__construct(moodle_url $url,pix_icon $icon,array $attributes = [],bool $popup = false,?lang_string $title = null)   X-Ref
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

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

add_callback(callable $callback)   X-Ref
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

return: self
param: callable $callback

get_action_link(stdClass $row)   X-Ref
Return action menu link suitable for output, or null if the action cannot be displayed (because one of its callbacks
returned false, {@see add_callback})

return: action_menu_link|null
param: stdClass $row

replace_placeholders(array $values, stdClass $row)   X-Ref
Given an array of values, replace all placeholders with corresponding property of the given row

return: array
param: string[] $values
param: stdClass $row