Does anyone know of a plugin that implements the restore hook "after_restore_module"? I have a local plugin that needs to perform something on a course module after it has been setup, but I need access to the newly created module and the module in the backup file's information. I created some custom tags in the module's module.xml file.
I tried using the define_module_plugin_structure() hook in the restore class for my plugin, but it appears that the data I set in the module's availability field is getting erased somewhere. So I think I need to do the setting of availability conditions after the module is fully restored.
I had a similar problem. I needed to update some values on a table after my module was restored. I did exactly what you said: first, implement define_module_plugin_structure() inside my restore class and return the paths for the data being restored and the functions for restoring it. Afterward, implement the after_restore_module() to restore all extra data getting the new module id and course id like this:
$cmid = $this->task->get_moduleid();
list($course, $cm) = get_course_and_cm_from_cmid($cmid, $modulename);
I hope this helps.
When I implemented define_module_plugin_structure() it gets passed a $data object. I am assuming I don't have access to that in after_restore_module(), so I need to store the $data object in a static variable or cache.
Then I can use that data in after_restore_module().
Glad I can get the moduleid in after_restore_module() and it is completely setup. So that should help. Would be nice to see a complete implementation by someone in the plugin database.
I am curious what in the restore code wipes out the availability data, because I am seeing that data set in the scope that define_module_plugin_structure() is called, but not after the restore is done.