Moodle  2.2.1
http://www.collinsharper.com
base_converter Class Reference
Inheritance diagram for base_converter:
Collaboration diagram for base_converter:

Public Member Functions

 __construct ($tempdir, $logger=null)
 set_logger ($logger)
 log ($message, $level, $a=null, $depth=null, $display=false)
 get_id ()
 get_name ()
 convert ()
 get_workdir_path ()
 get_tempdir_path ()

Static Public Member Functions

static is_available ()
 public static methods //////////////////////////////////////////////////
static detect_format ($tempdir)
static description ()

Protected Member Functions

 init ()
 end of public API //////////////////////////////////////////////////////
 execute ()
 create_workdir ()
 replace_tempdir ()
 destroy ()

Protected Attributes

 $id
 $tempdir
 $workdir
 $logger = null

Detailed Description

Base converter class

All Moodle backup converters are supposed to extend this base class.

Exceptions:
convert_exception

Definition at line 38 of file convertlib.php.


Constructor & Destructor Documentation

__construct ( tempdir,
logger = null 
)

Constructor

Parameters:
string$tempdirthe relative path to the directory containing the unpacked backup to convert
null|base_loggerlogger to use during the conversion

Definition at line 58 of file convertlib.php.

Here is the call graph for this function:


Member Function Documentation

convert ( )

Converts the backup directory

Definition at line 121 of file convertlib.php.

Here is the call graph for this function:

create_workdir ( ) [protected]

Prepares a new empty working directory

Definition at line 224 of file convertlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static 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 moodle1_converter, imscc11_converter, imscc1_converter, and imscc11_export_converter.

Definition at line 199 of file convertlib.php.

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.

Definition at line 260 of file convertlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static 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$tempdirthe name of the backup directory
Returns:
null|string null if not recognized, backup::FORMAT_xxx otherwise

Reimplemented in moodle1_converter, imscc11_converter, and imscc1_converter.

Definition at line 187 of file convertlib.php.

execute ( ) [abstract, protected]

Converts the contents of the tempdir into the target format in the workdir

Reimplemented in moodle1_converter, imscc11_converter, imscc1_converter, imscc11_export_converter, imscc1_export_converter, and moodle1_export_converter.

Here is the caller graph for this function:

get_id ( )

Get instance identifier

Returns:
string the unique identifier of this converter instance

Definition at line 105 of file convertlib.php.

Here is the caller graph for this function:

get_name ( )

Get converter name

Returns:
string the system name of the converter

Definition at line 114 of file convertlib.php.

Here is the caller graph for this function:

Returns:
string the full path to the directory with the source backup

Definition at line 156 of file convertlib.php.

Here is the caller graph for this function:

Returns:
string the full path to the working directory

Definition at line 147 of file convertlib.php.

Here is the caller graph for this function:

init ( ) [protected]

end of public API //////////////////////////////////////////////////////

Initialize the instance if needed, called by the constructor

Reimplemented in moodle1_converter.

Definition at line 213 of file convertlib.php.

Here is the caller graph for this function:

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

Returns:
boolean true if this converter should be considered as available

Reimplemented in imscc1_export_converter, and moodle1_export_converter.

Definition at line 172 of file convertlib.php.

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

Implements loggable.

Reimplemented in moodle1_converter, imscc11_converter, and imscc1_converter.

Definition at line 94 of file convertlib.php.

Here is the caller graph for this function:

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.

Definition at line 238 of file convertlib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

set_logger ( logger)

Sets the logger to use during the conversion

Parameters:
null | base_logger$logger

Definition at line 75 of file convertlib.php.

Here is the caller graph for this function:


Field Documentation

$id [protected]

Definition at line 41 of file convertlib.php.

$logger = null [protected]

Definition at line 50 of file convertlib.php.

$tempdir [protected]

Definition at line 44 of file convertlib.php.

$workdir [protected]

Definition at line 47 of file convertlib.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations