Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

State trait helper, with common methods.

Copyright: 2023 Sara Arjona (sara@moodle.com)
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 99 lines (3 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 4 functions


Functions that are not part of a class:

validate_component(string $component)   X-Ref
Check component name.

Note: this function is separated mainly for testing purposes to
be overridden to fake components.

param: string $component component name

get_agent_from_json(string $agentjson)   X-Ref
Convert a JSON agent into a valid item_agent.

param: string $agentjson JSON encoded agent structure
return: item_agent the agent

check_state_user(state $state)   X-Ref
Check that $USER is actor in state.

param: state $state The state
return: bool if $USER is actor of the state

get_statedata_from_json(string $statedatajson)   X-Ref
Convert the state data JSON into valid object.

param: string $statedatajson JSON encoded structure
return: stdClass the state data structure