Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 39 and 311] [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]

Provides {@link convert_helper} and {@link convert_helper_exception} classes

Copyright: 2011 Mark Nielsen <mark@moodlerooms.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 385 lines (14 kb)
Included or required:0 times
Referenced: 6 times
Includes or requires: 0 files

Defines 2 classes

convert_helper:: (8 methods):
  generate_id()
  available_converters()
  export_converter_dependencies()
  detect_moodle2_format()
  to_moodle2_format()
  set_inforef()
  get_inforef()
  choose_conversion_path()

convert_helper_exception:: (1 method):
  __construct()


Class: convert_helper  - X-Ref

Provides various functionality via its static methods

generate_id($entropy)   X-Ref

param: string $entropy
return: string random identifier

available_converters($restore=true)   X-Ref
Returns the list of all available converters and loads their classes

Converter must be installed as a directory in backup/converter/ and its
method is_available() must return true to get to the list.

return: array of strings

export_converter_dependencies($converter, $dependency)   X-Ref
No description

detect_moodle2_format($tempdir)   X-Ref
Detects if the given folder contains an unpacked moodle2 backup

param: string $tempdir the name of the backup directory
return: boolean true if moodle2 format detected, false otherwise

to_moodle2_format($tempdir, $format = null, $logger = null)   X-Ref
Converts the given directory with the backup into moodle2 format

param: string $tempdir The directory to convert
param: string $format The current format, if already detected
param: base_logger|null if the conversion should be logged, use this logger
return: bool false if unable to find the conversion path, true otherwise

set_inforef($contextid)   X-Ref
Inserts an inforef into the conversion temp table


get_inforef($contextid)   X-Ref
No description

choose_conversion_path($format, array $descriptions)   X-Ref
Choose the best conversion path for the given format

Given the source format and the list of available converters and their properties,
this methods picks the most effective way how to convert the source format into
the target moodle2 format. The method returns a list of converters that should be
called, in order.

This implementation uses Dijkstra's algorithm to find the shortest way through
the oriented graph.

param: string $format the source backup format, one of backup::FORMAT_xxx
param: array $descriptions list of {@link base_converter::description()} indexed by the converter name
author: David Mudrak <david@moodle.com>
return: array ordered list of converter names to call (may be empty if not reachable)

Class: convert_helper_exception  - X-Ref

General convert_helper related exception

__construct($errorcode, $a = null, $debuginfo = null)   X-Ref
Constructor

param: string $errorcode key for the corresponding error string
param: object $a extra words and phrases that might be required in the error string
param: string $debuginfo optional debugging information