Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 39 and 401]

(no description)

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

Defines 1 class


Class: XMLProcessor  - X-Ref

Class XMLProcessor
Helps process XML files

__construct($xmlReader)   X-Ref

param: \Box\Spout\Reader\Wrapper\XMLReader $xmlReader XMLReader object

registerCallback($nodeName, $nodeType, $callback)   X-Ref

param: string $nodeName A callback may be triggered when a node with this name is read
param: int $nodeType Type of the node [NODE_TYPE_START || NODE_TYPE_END]
param: callable $callback Callback to execute when the read node has the given name and type
return: XMLProcessor

getCallbackKey($nodeName, $nodeType)   X-Ref

param: string $nodeName Name of the node
param: int $nodeType Type of the node [NODE_TYPE_START || NODE_TYPE_END]
return: string Key used to store the associated callback

getInvokableCallbackData($callback)   X-Ref
Because the callback can be a "protected" function, we don't want to use call_user_func() directly
but instead invoke the callback using Reflection. This allows the invocation of "protected" functions.
Since some functions can be called a lot, we pre-process the callback to only return the elements that
will be needed to invoke the callback later.

param: callable $callback Array reference to a callback: [OBJECT, METHOD_NAME]
return: array Associative array containing the elements needed to invoke the callback using Reflection

readUntilStopped()   X-Ref
Resumes the reading of the XML file where it was left off.
Stops whenever a callback indicates that reading should stop or at the end of the file.

return: void

getRegisteredCallbackData($nodeNamePossiblyWithPrefix, $nodeNameWithoutPrefix, $nodeType)   X-Ref

param: string $nodeNamePossiblyWithPrefix Name of the node, possibly prefixed
param: string $nodeNameWithoutPrefix Name of the same node, un-prefixed
param: int $nodeType Type of the node [NODE_TYPE_START || NODE_TYPE_END]
return: array|null Callback data to be used for execution when a node of the given name/type is read or NULL if none found

invokeCallback($callbackData, $args)   X-Ref

param: array $callbackData Associative array containing data to invoke the callback using Reflection
param: array $args Arguments to pass to the callback
return: int Callback response