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)

Copyright: 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 548 lines (25 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: restore_structure_step  - X-Ref

Abstract class defining the needed stuff to restore one xml file

TODO: Finish phpdocs
__construct($name, $filename, $task = null)   X-Ref
Constructor - instantiates one object of this class


execute()   X-Ref
No description

process($data)   X-Ref
Receive one chunk of information form the xml parser processor and
dispatch it, following the naming rules


set_mapping($itemname, $oldid, $newid, $restorefiles = false, $filesctxid = null, $parentid = null)   X-Ref
To send ids pairs to backup_ids_table and to store them into paths

This method will send the given itemname and old/new ids to the
backup_ids_temp table, and, at the same time, will save the new id
into the corresponding restore_path_element for easier access
by children. Also will inject the known old context id for the task
in case it's going to be used for restoring files later

get_old_parentid($itemname)   X-Ref
Returns the latest (parent) old id mapped by one pathelement


get_new_parentid($itemname)   X-Ref
Returns the latest (parent) new id mapped by one pathelement


get_mappingid($itemname, $oldid, $ifnotfound = false)   X-Ref
Return the new id of a mapping for the given itemname

param: string $itemname the type of item
param: int $oldid the item ID from the backup
param: mixed $ifnotfound what to return if $oldid wasnt found. Defaults to false

get_mapping($itemname, $oldid)   X-Ref
Return the complete mapping from the given itemname, itemid


add_related_files($component, $filearea, $mappingitemname, $filesctxid = null, $olditemid = null)   X-Ref
Add all the existing file, given their component and filearea and one backup_ids itemname to match with


get_task()   X-Ref
As far as restore structure steps are implementing restore_plugin stuff, they need to
have the parent task available for wrapping purposes (get course/context....)

return: restore_task|null

add_plugin_structure($plugintype, $element)   X-Ref
Add plugin structure to any element in the structure restore tree

param: string $plugintype type of plugin as defined by core_component::get_plugin_types()
param: restore_path_element $element element in the structure restore tree that

add_subplugin_structure($subplugintype, $element, $plugintype = null, $pluginname = null)   X-Ref
Add subplugin structure for a given plugin to any element in the structure restore tree

This method allows the injection of subplugins (of a specific plugin) parsing and proccessing
to any element in the restore structure.

NOTE: Initially subplugins were only available for activities (mod), so only the
{@link restore_activity_structure_step} class had support for them, always
looking for /mod/modulenanme subplugins. This new method is a generalization of the
existing one for activities, supporting all subplugins injecting information everywhere.

return: void
param: string $subplugintype type of subplugin as defined in plugin's db/subplugins.json.
param: restore_path_element $element element in the structure restore tree that
param: string $plugintype type of the plugin.
param: string $pluginname name of the plugin.

launch_after_execute_methods()   X-Ref
Launch all the after_execute methods present in all the processing objects

This method will launch all the after_execute methods that can be defined
both in restore_plugin and restore_structure_step classes

For restore_plugin classes the name of the method to be executed will be
"after_execute_" + connection point (as far as can be multiple connection
points in the same class)

For restore_structure_step classes is will be, simply, "after_execute". Note
that this is executed *after* the plugin ones

launch_after_restore_methods()   X-Ref
Launch all the after_restore methods present in all the processing objects

This method will launch all the after_restore methods that can be defined
both in restore_plugin class

For restore_plugin classes the name of the method to be executed will be
"after_restore_" + connection point (as far as can be multiple connection
points in the same class)

after_execute()   X-Ref
This method will be executed after the whole structure step have been processed

After execution method for code needed to be executed after the whole structure
has been processed. Useful for cleaning tasks, files process and others. Simply
overwrite in in your steps if needed

after_restore()   X-Ref
This method will be executed after the rest of the restore has been processed.

Use if you need to update IDs based on things which are restored after this
step has completed.

prepare_pathelements($elementsarr)   X-Ref
Prepare the pathelements for processing, looking for duplicates, applying
processing objects and other adjustments


grouped_parent_exists($pelement, $elements)   X-Ref
Given one pathelement, return true if grouped parent was found

return: bool true if this element is inside a grouped parent.
param: restore_path_element $pelement the element we are interested in.
param: restore_path_element[] $elements the elements that exist.

execute_condition()   X-Ref
To conditionally decide if one step will be executed or no

For steps needing to be executed conditionally, based in dynamic
conditions (at execution time vs at declaration time) you must
override this function. It will return true if the step must be
executed and false if not