Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
async_helper Class Reference

Helper functions for asynchronous backups and restores. More...

Public Member Functions

 __construct ($type, $id)
 Class constructor. More...
 
 send_message ()
 Sends a confirmation message for an aynchronous process. More...
 

Static Public Member Functions

static get_async_backups ($renderer, $instanceid)
 Get markup for in progress async backups, to use in backup table UI. More...
 
static get_async_restores ($userid)
 Get all the current in progress async restores for a user. More...
 
static get_backup_file_info ($filename, $filearea, $contextid)
 Get the size, url and restore url for a backup file. More...
 
static get_backup_record ($id)
 Given a backup id return a the record from the database. More...
 
static get_restore_name (\context $context)
 Get the course name of the resource being restored. More...
 
static get_restore_url ($backupid)
 Get the url of a restored backup item based on the backup ID. More...
 
static is_async_enabled ()
 Check if asynchronous backup and restore mode is enabled at system level. More...
 
static is_async_pending ($id, $type, $operation)
 Check if there is a pending async operation for given details. More...
 

Protected Attributes

string $backupid
 $backupid The id of the backup or restore.
 
object $backuprec
 $backuprec The backup controller record from the database.
 
string $type = 'backup'
 $type The type of async operation.
 
object $user
 $user The user who created the backup record.
 

Detailed Description

Helper functions for asynchronous backups and restores.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

async_helper::__construct (   $type,
  $id 
)

Class constructor.

Parameters
string$typeThe type of async operation.
string$idThe id of the backup or restore.

Member Function Documentation

◆ get_async_backups()

static async_helper::get_async_backups (   $renderer,
  $instanceid 
)
static

Get markup for in progress async backups, to use in backup table UI.

Parameters
core_backup_renderer$rendererThe backup renderer object.
integer$instanceidThe context id to get backup data for.
Return values
array::$tabledatathe rows of table data.

◆ get_async_restores()

static async_helper::get_async_restores (   $userid)
static

Get all the current in progress async restores for a user.

Parameters
int$useridMoodle user id.
Return values
array::$restoresList of current restores in progress.

◆ get_backup_file_info()

static async_helper::get_backup_file_info (   $filename,
  $filearea,
  $contextid 
)
static

Get the size, url and restore url for a backup file.

Parameters
string$filenameThe name of the file to get info for.
string$fileareaThe file area for the file.
int$contextidThe context ID of the file.
Return values
array::$resultsThe result array containing the size, url and restore url of the file.

◆ get_backup_record()

static async_helper::get_backup_record (   $id)
static

Given a backup id return a the record from the database.

We use this method rather than 'load_controller' as the controller may not exist if this backup/restore has completed.

Parameters
int$idThe backup id to get.
Return values
object::$backuprecThe backup controller record.

◆ get_restore_name()

static async_helper::get_restore_name ( \context  $context)
static

Get the course name of the resource being restored.

Parameters
context$contextThe Moodle context for the restores.
Return values
string::$coursenameThe full name of the course.

◆ get_restore_url()

static async_helper::get_restore_url (   $backupid)
static

Get the url of a restored backup item based on the backup ID.

Parameters
string$backupidThe backup ID to get the restore location url.
Return values
array::$urlarrayThe restored item URL as an array.

◆ is_async_enabled()

static async_helper::is_async_enabled ( )
static

Check if asynchronous backup and restore mode is enabled at system level.

Return values
bool::$asyncTrue if async mode enabled false otherwise.

◆ is_async_pending()

static async_helper::is_async_pending (   $id,
  $type,
  $operation 
)
static

Check if there is a pending async operation for given details.

Parameters
int$idThe item id to check in the backup record.
string$typeThe type of operation: course, activity or section.
string$operationOperation backup or restore.
Return values
boolean::$asyncpedningIs there a pending async operation.

◆ send_message()

async_helper::send_message ( )

Sends a confirmation message for an aynchronous process.

Return values
int::$messageidThe id of the sent message.

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