Base converter class.
More...
|
| __construct ($tempdir, $logger=null) |
| Constructor.
|
|
| convert () |
| Converts the backup directory.
|
|
| get_id () |
| Get instance identifier.
|
|
| get_name () |
| Get converter name.
|
|
| get_tempdir_path () |
|
| get_workdir_path () |
|
| 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.
|
|
| set_logger ($logger) |
| Sets the logger to use during the conversion.
|
|
|
static | description () |
| Returns the basic information about the converter.
|
|
static | detect_format ($tempdir) |
| Detects the format of the backup directory.
|
|
static | is_available () |
| public static methods //////////////////////////////////////////////////
|
|
|
| create_workdir () |
| Prepares a new empty working directory.
|
|
| destroy () |
| Cleans up stuff after the execution.
|
|
| execute () |
| Converts the contents of the tempdir into the target format in the workdir.
|
|
| init () |
| end of public API //////////////////////////////////////////////////////
|
|
| replace_tempdir () |
| Replaces the source backup directory with the converted version.
|
|
|
string | $id |
| unique identifier of this converter instance
|
|
null base_logger | $logger = null |
| logger to use during the conversion
|
|
string | $tempdir |
| the name of the directory containing the unpacked backup being converted
|
|
string | $workdir |
| the name of the directory where the backup is converted to
|
|
Base converter class.
All Moodle backup converters are supposed to extend this base class.
- Exceptions
-
◆ __construct()
base_converter::__construct |
( |
| $tempdir, |
|
|
| $logger = null ) |
Constructor.
- Parameters
-
string | $tempdir | the relative path to the directory containing the unpacked backup to convert |
| null|base_logger | logger to use during the conversion |
◆ description()
static base_converter::description |
( |
| ) |
|
|
static |
Returns the basic information about the converter.
The returned array must contain the following keys: 'from' - the supported source format, eg. backup\FORMAT_MOODLE1 'to' - the supported target format, eg. backup\FORMAT_MOODLE 'cost' - the cost of the conversion, non-negative non-zero integer
Reimplemented in imscc11_converter, imscc11_export_converter, imscc1_converter, and moodle1_converter.
◆ destroy()
base_converter::destroy |
( |
| ) |
|
|
protected |
Cleans up stuff after the execution.
Note that we do not know if the execution was successful or not. An exception might have been thrown.
◆ detect_format()
static base_converter::detect_format |
( |
| $tempdir | ) |
|
|
static |
Detects the format of the backup directory.
Moodle 2.x format is being detected by the core itself. The converters are therefore supposed to detect the source format. Eventually, if the target format os not backup::FORMAT_MOODLE then they should be able to detect both source and target formats.
- Parameters
-
string | $tempdir | the name of the backup directory |
- Return values
-
null|string | null if not recognized, backup\FORMAT_xxx otherwise |
Reimplemented in imscc11_converter, imscc1_converter, and moodle1_converter.
◆ execute()
base_converter::execute |
( |
| ) |
|
|
abstractprotected |
◆ get_id()
base_converter::get_id |
( |
| ) |
|
Get instance identifier.
- Return values
-
string | the unique identifier of this converter instance |
◆ get_name()
base_converter::get_name |
( |
| ) |
|
Get converter name.
- Return values
-
string | the system name of the converter |
◆ get_tempdir_path()
base_converter::get_tempdir_path |
( |
| ) |
|
- Return values
-
string | the full path to the directory with the source backup |
◆ get_workdir_path()
base_converter::get_workdir_path |
( |
| ) |
|
- Return values
-
string | the full path to the working directory |
◆ init()
end of public API //////////////////////////////////////////////////////
Initialize the instance if needed, called by the constructor
Reimplemented in moodle1_converter.
◆ is_available()
static base_converter::is_available |
( |
| ) |
|
|
static |
public static methods //////////////////////////////////////////////////
Makes sure that this converter is available at this site
This is intended for eventual PHP extensions check, environment check etc. All checks that do not depend on actual backup data should be done here.
- Return values
-
boolean | true if this converter should be considered as available |
Reimplemented in imscc1_export_converter, and moodle1_export_converter.
◆ log()
base_converter::log |
( |
| $message, |
|
|
| $level, |
|
|
| $a = null, |
|
|
| $depth = null, |
|
|
| $display = false ) |
◆ replace_tempdir()
base_converter::replace_tempdir |
( |
| ) |
|
|
protected |
Replaces the source backup directory with the converted version.
If $CFG->keeptempdirectoriesonbackup is defined, the original source source backup directory is kept for debugging purposes.
◆ set_logger()
base_converter::set_logger |
( |
| $logger | ) |
|
Sets the logger to use during the conversion.
- Parameters
-
The documentation for this class was generated from the following file: