Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
|
Static Public Member Functions | |
static | call_external_function ($function, $args, $ajaxonly=false) |
Call an external function validating all params/returns correctly. More... | |
static | clean_returnvalue (external_description $description, $response) |
Clean response If a response attribute is unknown from the description, we just ignore the attribute. More... | |
static | external_function_info ($function, $strictness=MUST_EXIST) |
Returns detailed function information. More... | |
static | get_files ($contextid, $component, $filearea, $itemid, $filepath, $filename, $modified=null, $contextlevel=null, $instanceid=null) |
Return moodle files listing. More... | |
static | get_files_parameters () |
Returns description of get_files parameters. More... | |
static | get_files_returns () |
Returns description of get_files returns. More... | |
static | set_context_restriction ($context) |
Set context restriction for all following subsequent function calls. More... | |
static | set_timeout ($seconds=360) |
This method has to be called before every operation that takes a longer time to finish! More... | |
static | upload ($contextid, $component, $filearea, $itemid, $filepath, $filename, $filecontent, $contextlevel, $instanceid) |
Uploading a file to moodle. More... | |
static | upload_parameters () |
Returns description of upload parameters. More... | |
static | upload_returns () |
Returns description of upload returns. More... | |
static | validate_context ($context) |
Makes sure user may execute functions in this context. More... | |
static | validate_parameters (external_description $description, $params) |
Validates submitted function parameters, if anything is incorrect invalid_parameter_exception is thrown. More... | |
Static Protected Member Functions | |
static | get_context_from_params ($param) |
Get context from passed parameters. More... | |
static | get_context_parameters () |
Returns a prepared structure to use a context parameters. More... | |
|
staticinherited |
Call an external function validating all params/returns correctly.
Note that an external function may modify the state of the current page, so this wrapper saves and restores tha PAGE and COURSE global variables before/after calling the external function.
string | $function | A webservice function name. |
array | $args | Params array (named params) |
boolean | $ajaxonly | If true, an extra check will be peformed to see if ajax is required. |
array | containing keys for error (bool), exception and data. |
|
staticinherited |
Clean response If a response attribute is unknown from the description, we just ignore the attribute.
If a response attribute is incorrect, invalid_response_exception is thrown. Note: this function is similar to validate parameters, however it is distinct because parameters validation must be distinct from cleaning return values.
external_description | $description | description of the return values |
mixed | $response | the actual response |
mixed | response with added defaults for optional items, invalid_response_exception thrown if any problem found |
|
staticinherited |
Returns detailed function information.
string | object | $function | name of external function or record from external_function |
int | $strictness | IGNORE_MISSING means compatible mode, false returned if record not found, debug message if more found; MUST_EXIST means throw exception if no record or multiple records found |
stdClass | description or false if not found or exception thrown |
|
staticprotectedinherited |
Get context from passed parameters.
The passed array must either contain a contextid or a combination of context level and instance id to fetch the context. For example, the context level can be "course" and instanceid can be courseid.
See context_helper::get_all_levels() for a list of valid context levels.
array | $param |
invalid_parameter_exception |
context |
|
staticprotectedinherited |
Returns a prepared structure to use a context parameters.
external_single_structure |
Reimplemented in tool_lp\external, and core_competency\external.
|
static |
Return moodle files listing.
int | $contextid | context id |
int | $component | component |
int | $filearea | file area |
int | $itemid | item id |
string | $filepath | file path |
string | $filename | file name |
int | $modified | timestamp to return files changed after this time. |
string | $contextlevel | The context level for the file location. |
int | $instanceid | The instance id for where the file is located. |
array |
|
static |
Returns description of get_files parameters.
external_function_parameters |
|
static |
Returns description of get_files returns.
external_single_structure |
|
staticinherited |
Set context restriction for all following subsequent function calls.
stdClass | $context | the context restriction |
|
staticinherited |
This method has to be called before every operation that takes a longer time to finish!
int | $seconds | max expected time the next operation needs |
|
static |
Uploading a file to moodle.
int | $contextid | context id |
string | $component | component |
string | $filearea | file area |
int | $itemid | item id |
string | $filepath | file path |
string | $filename | file name |
string | $filecontent | file content |
string | $contextlevel | Context level (block, course, coursecat, system, user or module) |
int | $instanceid | Instance id of the item associated with the context level |
array |
|
static |
Returns description of upload parameters.
external_function_parameters |
|
static |
|
staticinherited |
Makes sure user may execute functions in this context.
stdClass | $context |
|
staticinherited |
Validates submitted function parameters, if anything is incorrect invalid_parameter_exception is thrown.
This is a simple recursive method which is intended to be called from each implementation method of external API.
external_description | $description | description of parameters |
mixed | $params | the actual parameters |
mixed | params with added defaults for optional items, invalid_parameters_exception thrown if any problem found |