Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
restore_structure_step Class Reference

Abstract class defining the needed stuff to restore one xml file. More...

Inheritance diagram for restore_structure_step:
restore_step base_step executable loggable restore_activity_competencies_structure_step restore_activity_grade_history_structure_step restore_activity_grades_structure_step restore_activity_grading_structure_step restore_activity_structure_step restore_badges_structure_step restore_block_instance_structure_step restore_calendarevents_structure_step restore_comments_structure_step restore_contentbankcontent_structure_step restore_course_competencies_structure_step restore_course_completion_structure_step restore_course_loglastaccess_structure_step restore_course_logs_structure_step restore_course_logstores_structure_step restore_course_structure_step restore_create_categories_and_questions restore_enrolments_structure_step restore_filters_structure_step restore_grade_history_structure_step restore_gradebook_structure_step restore_groups_members_structure_step restore_groups_structure_step restore_load_included_files restore_module_structure_step restore_outcomes_structure_step restore_ras_and_caps_structure_step restore_rss_client_block_structure_step restore_scales_structure_step restore_section_structure_step restore_userscompletion_structure_step restore_xapistate_structure_step

Public Member Functions

 __construct ($name, $filename, $task=null)
 Constructor - instantiates one object of this class.
 
 add_related_files ($component, $filearea, $mappingitemname, $filesctxid=null, $olditemid=null)
 Add all the existing file, given their component and filearea and one backup_ids itemname to match with.
 
 apply_date_offset ($value)
 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.
 
 decrypt ($value)
 Returns symmetric-key AES-256 decryption of base64 encoded contents.
 
 destroy ()
 Destroy all circular references.
 
 execute ()
 This function will perform all the actions necessary to achieve the execution of the plan/part/task.
 
 get_mapping ($itemname, $oldid)
 Return the complete mapping from the given itemname, itemid.
 
 get_mappingid ($itemname, $oldid, $ifnotfound=false)
 Return the new id of a mapping for the given itemname.
 
 get_name ()
 
 get_new_parentid ($itemname)
 Returns the latest (parent) new id mapped by one pathelement.
 
 get_old_parentid ($itemname)
 Returns the latest (parent) old id mapped by one pathelement.
 
 get_task ()
 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....)
 
 grouped_parent_exists ($pelement, $elements)
 Given one pathelement, return true if grouped parent was found.
 
 launch_after_restore_methods ()
 Launch all the after_restore methods present in all the processing objects.
 
 log ($message, $level, $a=null, $depth=null, $display=false)
 This function will be responsible for handling the params, and to call to the corresponding logger->process() once all modifications in params have been performed.
 
 process ($data)
 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)
 To send ids pairs to backup_ids_table and to store them into paths.
 
 set_task ($task)
 

Public Attributes

const SKIP_ALL_CHILDREN = -991399
 

Protected Member Functions

 add_plugin_structure ($plugintype, $element)
 Add plugin structure to any element in the structure restore tree.
 
 add_subplugin_structure ($subplugintype, $element, $plugintype=null, $pluginname=null)
 Add subplugin structure for a given plugin to any element in the structure restore tree.
 
 after_execute ()
 This method will be executed after the whole structure step have been processed.
 
 after_restore ()
 This method will be executed after the rest of the restore has been processed.
 
 define_structure ()
 Function that will return the structure to be processed by this restore_step.
 
 execute_condition ()
 To conditionally decide if one step will be executed or no.
 
 get_basepath ()
 
 get_courseid ()
 
 get_logger ()
 
 get_restoreid ()
 
 get_setting ($name)
 
 get_setting_value ($name)
 
 get_settings ()
 Protected API starts here.
 
 launch_after_execute_methods ()
 Launch all the after_execute methods present in all the processing objects.
 
 prepare_pathelements ($elementsarr)
 Prepare the pathelements for processing, looking for duplicates, applying processing objects and other adjustments.
 
 setting_exists ($name)
 

Protected Attributes

 $contentprocessor
 
 $elementsnewid
 
 $elementsoldid
 
 $filename
 
string $name
 One simple name for identification purposes.
 
 $pathelements
 
 $pathlock
 
base_task null $task
 Task this is part of.
 

Detailed Description

Abstract class defining the needed stuff to restore one xml file.

TODO: Finish phpdocs

Member Function Documentation

◆ add_plugin_structure()

restore_structure_step::add_plugin_structure ( $plugintype,
$element )
protected

Add plugin structure to any element in the structure restore tree.

Parameters
string$plugintypetype of plugin as defined by core_component\get_plugin_types()
restore_path_element$elementelement in the structure restore tree that we are going to add plugin information to

◆ add_subplugin_structure()

restore_structure_step::add_subplugin_structure ( $subplugintype,
$element,
$plugintype = null,
$pluginname = null )
protected

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 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.

Parameters
string$subplugintypetype of subplugin as defined in plugin's db/subplugins.json.
restore_path_element$elementelement in the structure restore tree that we are going to add subplugin information to.
string$plugintypetype of the plugin.
string$pluginnamename of the plugin.
Return values
void

◆ after_execute()

restore_structure_step::after_execute ( )
protected

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

Reimplemented in restore_activity_grading_structure_step, restore_assign_activity_structure_step, restore_badges_structure_step, restore_bigbluebuttonbn_activity_structure_step, restore_book_activity_structure_step, restore_calendarevents_structure_step, restore_chat_activity_structure_step, restore_choice_activity_structure_step, restore_contentbankcontent_structure_step, restore_course_structure_step, restore_create_categories_and_questions, restore_data_activity_structure_step, restore_feedback_activity_structure_step, restore_folder_activity_structure_step, restore_forum_activity_structure_step, restore_glossary_activity_structure_step, restore_gradebook_structure_step, restore_groups_structure_step, restore_h5pactivity_activity_structure_step, restore_imscp_activity_structure_step, restore_label_activity_structure_step, restore_lesson_activity_structure_step, restore_lti_activity_structure_step, restore_outcomes_structure_step, restore_page_activity_structure_step, restore_resource_activity_structure_step, restore_scales_structure_step, restore_scorm_activity_structure_step, restore_section_structure_step, restore_survey_activity_structure_step, restore_url_activity_structure_step, restore_wiki_activity_structure_step, and restore_workshop_activity_structure_step.

◆ after_restore()

restore_structure_step::after_restore ( )
protected

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.

Reimplemented in restore_activity_grades_structure_step, restore_forum_activity_structure_step, and restore_module_structure_step.

◆ apply_date_offset()

restore_step::apply_date_offset ( $value)
inherited

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.

Note: The policy is to roll date only for configurations and not for user data. see MDL-9367.

Parameters
int$valueTime value (seconds since epoch), or empty for nothing
Return values
intTime value after applying the date offset, or empty for nothing

◆ decrypt()

restore_step::decrypt ( $value)
inherited

Returns symmetric-key AES-256 decryption of base64 encoded contents.

This method is used in restore operations to decrypt contents encrypted with encrypted_final_element automatically decoding (base64) and decrypting contents using the key stored in backup_encryptkey config.

Requires openssl, cipher availability, and key existence (backup automatically sets it if missing). Integrity is provided via HMAC.

Parameters
string$valueencrypted_final_element value to decode and decrypt.
Return values
string|nulldecoded and decrypted value or null if the operation can not be performed.

◆ define_structure()

restore_structure_step::define_structure ( )
abstractprotected

Function that will return the structure to be processed by this restore_step.

Must return one array of @restore_path_element elements

Reimplemented in restore_activity_competencies_structure_step, restore_activity_grade_history_structure_step, restore_activity_grades_structure_step, restore_activity_grading_structure_step, restore_assign_activity_structure_step, restore_badges_structure_step, restore_bigbluebuttonbn_activity_structure_step, restore_block_instance_structure_step, restore_book_activity_structure_step, restore_calendarevents_structure_step, restore_chat_activity_structure_step, restore_choice_activity_structure_step, restore_comments_structure_step, restore_contentbankcontent_structure_step, restore_course_competencies_structure_step, restore_course_completion_structure_step, restore_course_loglastaccess_structure_step, restore_course_logs_structure_step, restore_course_logstores_structure_step, restore_course_structure_step, restore_create_categories_and_questions, restore_data_activity_structure_step, restore_enrolments_structure_step, restore_feedback_activity_structure_step, restore_filters_structure_step, restore_folder_activity_structure_step, restore_forum_activity_structure_step, restore_glossary_activity_structure_step, restore_grade_history_structure_step, restore_gradebook_structure_step, restore_groups_members_structure_step, restore_groups_structure_step, restore_h5pactivity_activity_structure_step, restore_imscp_activity_structure_step, restore_label_activity_structure_step, restore_lesson_activity_structure_step, restore_load_included_files, restore_lti_activity_structure_step, restore_module_structure_step, restore_outcomes_structure_step, restore_page_activity_structure_step, restore_ras_and_caps_structure_step, restore_resource_activity_structure_step, restore_rss_client_block_structure_step, restore_scales_structure_step, restore_scorm_activity_structure_step, restore_section_structure_step, restore_survey_activity_structure_step, restore_url_activity_structure_step, restore_userscompletion_structure_step, restore_wiki_activity_structure_step, restore_workshop_activity_structure_step, and restore_xapistate_structure_step.

◆ destroy()

base_step::destroy ( )
inherited

Destroy all circular references.

It helps PHP 5.2 a lot!

◆ execute()

restore_structure_step::execute ( )
final

This function will perform all the actions necessary to achieve the execution of the plan/part/task.

Implements executable.

◆ execute_condition()

restore_structure_step::execute_condition ( )
protected

◆ get_mappingid()

restore_structure_step::get_mappingid ( $itemname,
$oldid,
$ifnotfound = false )

Return the new id of a mapping for the given itemname.

Parameters
string$itemnamethe type of item
int$oldidthe item ID from the backup
mixed$ifnotfoundwhat to return if $oldid wasnt found. Defaults to false

◆ get_task()

restore_structure_step::get_task ( )

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 values
restore_task|null

◆ grouped_parent_exists()

restore_structure_step::grouped_parent_exists ( $pelement,
$elements )

Given one pathelement, return true if grouped parent was found.

Parameters
restore_path_element$pelementthe element we are interested in.
restore_path_element[]$elementsthe elements that exist.
Return values
booltrue if this element is inside a grouped parent.

◆ launch_after_execute_methods()

restore_structure_step::launch_after_execute_methods ( )
protected

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()

restore_structure_step::launch_after_restore_methods ( )

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)

◆ log()

base_step::log ( $message,
$level,
$a = null,
$depth = null,
$display = false )
inherited

This function will be responsible for handling the params, and to call to the corresponding logger->process() once all modifications in params have been performed.

Implements loggable.

◆ set_mapping()

restore_structure_step::set_mapping ( $itemname,
$oldid,
$newid,
$restorefiles = false,
$filesctxid = null,
$parentid = null )

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


The documentation for this class was generated from the following file: