See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401]
Backup controller and related exception classes.
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: | 662 lines (24 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
backup_controller:: (33 methods):
__construct()
destroy()
finish_ui()
process_ui_event()
set_status()
set_execution()
calculate_checksum()
is_checksum_correct()
get_backupid()
get_type()
get_include_files()
get_include_files_default()
get_operation()
get_id()
get_courseid()
get_format()
get_interactive()
get_mode()
get_userid()
get_status()
get_execution()
get_executiontime()
get_plan()
debug_display_all_settings_values()
set_kept_roles()
execute_plan()
get_results()
save_controller()
load_controller()
calculate_backupid()
load_plan()
apply_defaults()
set_include_files()
backup_controller_exception:: (1 method):
__construct()
Class: backup_controller - X-Ref
Class implementing the controller of any backup process__construct($type, $id, $format, $interactive, $mode, $userid, $releasesession = backup::RELEASESESSION_NO) X-Ref |
Constructor for the backup controller class. param: string $type Type of the backup; One of backup::TYPE_1COURSE, TYPE_1SECTION, TYPE_1ACTIVITY param: int $id The ID of the item to backup; e.g the course id param: string $format The backup format to use; Most likely backup::FORMAT_MOODLE param: bool $interactive Whether this backup will require user interaction; backup::INTERACTIVE_YES or INTERACTIVE_NO param: int $mode One of backup::MODE_GENERAL, MODE_IMPORT, MODE_SAMESITE, MODE_HUB, MODE_AUTOMATED param: int $userid The id of the user making the backup param: bool $releasesession Should release the session? backup::RELEASESESSION_YES or backup::RELEASESESSION_NO |
destroy() X-Ref |
Clean structures used by the backup_controller This method clean various structures used by the backup_controller, destroying them in an ordered way, so their memory will be gc properly by PHP (mainly circular references). Note that, while it's not mandatory to execute this method, it's highly recommended to do so, specially in scripts performing multiple operations (like the automated backups) or the system will run out of memory after a few dozens of backups) |
finish_ui() X-Ref |
Declare that all user interaction with the backup controller is complete. After this the backup controller is waiting for processing. |
process_ui_event() X-Ref |
Validates the backup is valid after any user changes. A backup_controller_exception will be thrown if there is an issue. |
set_status($status) X-Ref |
Sets the new status of the backup. param: int $status |
set_execution($execution, $executiontime = 0) X-Ref |
Sets if the backup will be processed immediately, or later. param: int $execution Use backup::EXECUTION_INMEDIATE or backup::EXECUTION_DELAYED param: int $executiontime The timestamp in the future when the task should be executed, or 0 for immediately. |
calculate_checksum() X-Ref |
No description |
is_checksum_correct($checksum) X-Ref |
No description |
get_backupid() X-Ref |
Gets the unique identifier for this backup controller. return: string |
get_type() X-Ref |
Gets the type of backup to be performed. Use {@see \backup_controller::get_id()} to find the instance being backed up. return: string |
get_include_files() X-Ref |
Returns the current value of the include_files setting. This setting is intended to ensure that files are not included in generated backups. return: int Indicates whether files should be included in backups. |
get_include_files_default() X-Ref |
Returns the default value for $this->includefiles before we consider any settings. return: bool |
get_operation() X-Ref |
Gets if this is a backup or restore. return: string |
get_id() X-Ref |
Gets the instance id of the item being backed up. It's meaning is related to the type of backup {@see \backup_controller::get_type()}. return: int |
get_courseid() X-Ref |
Gets the course that the item being backed up is in. return: false|int |
get_format() X-Ref |
Gets the format the backup is stored in. return: string |
get_interactive() X-Ref |
Gets if user interaction is expected during the backup. return: bool |
get_mode() X-Ref |
Gets the mode that the backup will be performed in. return: int |
get_userid() X-Ref |
Get the id of the user who started the backup. return: int |
get_status() X-Ref |
Get the current status of the backup. return: int |
get_execution() X-Ref |
Get if the backup will be executed immediately, or later. return: int |
get_executiontime() X-Ref |
Get when the backup will be executed. return: int 0 means now, otherwise a Unix timestamp |
get_plan() X-Ref |
Gets the plan that will be run during the backup. return: backup_plan |
debug_display_all_settings_values() X-Ref |
For debug only. Get a simple test display of all the settings. return: string |
set_kept_roles(array $roleids) X-Ref |
Sets the user roles that should be kept in the destination course for a course copy operation. param: array $roleids |
execute_plan() X-Ref |
Executes the backup return: void Throws and exception of completes |
get_results() X-Ref |
Gets the results of the plan execution for this backup. return: array |
save_controller($includeobj = true, $cleanobj = false) X-Ref |
Save controller information param: bool $includeobj to decide if the object itself must be updated (true) or no (false) param: bool $cleanobj to decide if the object itself must be cleaned (true) or no (false) |
load_controller($backupid) X-Ref |
Loads a backup controller from the database. param: string $backupid The id of the backup controller. return: \backup_controller |
calculate_backupid() X-Ref |
Creates a unique id for this backup. |
load_plan() X-Ref |
Builds the plan for this backup job so that it may be executed. |
apply_defaults() X-Ref |
Sets default values for the backup controller. |
set_include_files(bool $includefiles) X-Ref |
Set the initial value for the include_files setting. param: bool $includefiles |
Class: backup_controller_exception - X-Ref
Exception class used by all the @backup_controller stuff__construct($errorcode, $a=NULL, $debuginfo=null) X-Ref |
No description |