mirrored from git://git.moodle.org/moodle.git
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added converter format detection and added conversion logic to restor…
…e controller
- Loading branch information
Showing
6 changed files
with
88 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
abstract class convert_factory { | ||
/** | ||
* @static | ||
* @throws coding_exception | ||
* @param $name The converter name | ||
* @param $tempdir The temp directory to operate on | ||
* @return base_converter|plan_converter | ||
*/ | ||
public static function converter($name, $tempdir) { | ||
global $CFG; | ||
|
||
$name = clean_param($name, PARAM_SAFEDIR); | ||
|
||
$classfile = "$CFG->dirroot/backup/converter/$name.class.php"; | ||
$classname = "{$name}_converter"; | ||
|
||
if (!file_exists($classfile)) { | ||
throw new coding_exception("Converter factory error: class file not found $classfile"); | ||
} | ||
require_once($classfile); | ||
|
||
if (!class_exists($classname)) { | ||
throw new coding_exception("Converter factory error: class not found $classname"); | ||
} | ||
return new $classname($tempdir); | ||
} | ||
|
||
/** | ||
* @static | ||
* @param string $tempdir The temp directory to operate on | ||
* @return array | ||
*/ | ||
public static function converters($tempdir) { | ||
global $CFG; | ||
|
||
$converters = array(); | ||
$files = get_directory_list($CFG->dirroot.'/backup/converter'); | ||
foreach ($files as $file) { | ||
$name = array_shift(explode('_', $file)); | ||
$converters[$name] = self::converter($name, $tempdir); | ||
} | ||
return $converters; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters