Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 402] [Versions 310 and 403]

Defines restore_plugin class

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: 284 lines (11 kb)
Included or required:0 times
Referenced: 1 time
Includes or requires: 0 files

Defines 1 class


Class: restore_plugin  - X-Ref

Class implementing the plugins support for moodle2 restore

TODO: Finish phpdocs
__construct($plugintype, $pluginname, $step)   X-Ref
restore_plugin constructor.

param: string $plugintype
param: string $pluginname
param: restore_structure_step $step

define_plugin_structure($connectionpoint)   X-Ref
No description

launch_after_execute_methods()   X-Ref
after_execute dispatcher for any restore_plugin class

This method will dispatch execution to the corresponding
after_execute_xxx() method when available, with xxx
being the connection point of the instance, so plugin
classes with multiple connection points will support
multiple after_execute methods, one for each connection point

launch_after_restore_methods()   X-Ref
after_restore dispatcher for any restore_plugin class

This method will dispatch execution to the corresponding
after_restore_xxx() method when available, with xxx
being the connection point of the instance, so plugin
classes with multiple connection points will support
multiple after_restore methods, one for each connection point

get_restore_decode_contents($plugintype)   X-Ref
Returns one array with all the decode contents
to be processed by the links decoder

This method, given one plugin type, returns one
array of {@link restore_decode_content} objects
that will be added to the restore decoder in order
to perform modifications under the plugin contents.

The objects are retrieved by calling to the {@link define_decode_contents}
method (when available), first in the main restore_xxxx_plugin class
and later on each of the available subclasses

define_plugin_decode_contents()   X-Ref
Define the contents in the plugin that must be
processed by the link decoder


get_restoreid()   X-Ref
No description

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


apply_date_offset($value)   X-Ref
Apply course startdate offset based in original course startdate and course_offset_startdate setting
Note we are using one static cache here, but *by restoreid*, so it's ok for concurrence/multiple
executions in the same request


get_setting_value($name)   X-Ref
Returns the value of one (task/plan) setting


get_namefor($name = '')   X-Ref
Simple helper function that returns the name for the restore_path_element
It's not mandatory to use it but recommended ;-)


get_pathfor($path = '')   X-Ref
Simple helper function that returns the base (prefix) of the path for the restore_path_element
Useful if we used get_recommended_name() in backup. It's not mandatory to use it but recommended ;-)


get_task()   X-Ref
Get the task we are part of.

return: restore_activity_task|restore_course_task the task.