Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 39 and 401]

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: 387 lines (15 kb)
Included or required:0 times
Referenced: 3 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