forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDL-21432 backup - using grouped parser in moodle_backup.xml + minor …
…changes in common stuff
- Loading branch information
Showing
4 changed files
with
159 additions
and
5 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
58 changes: 58 additions & 0 deletions
58
backup/util/helper/restore_moodlexml_parser_processor.class.php
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,58 @@ | ||
<?php | ||
|
||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* @package moodlecore | ||
* @subpackage backup-helper | ||
* @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
require_once($CFG->dirroot.'/backup/util/xml/parser/processors/grouped_parser_processor.class.php'); | ||
|
||
/** | ||
* helper implementation of grouped_parser_processor that will | ||
* return all the information present in the moodle_backup.xml file | ||
* accumulating it for later generation of controller->info | ||
* | ||
* TODO: Complete phpdocs | ||
*/ | ||
class restore_moodlexml_parser_processor extends grouped_parser_processor { | ||
|
||
protected $accumchunks; | ||
|
||
public function __construct() { | ||
$this->accumchunks = array(); | ||
parent::__construct(); | ||
// Let's add all the paths we are interested on | ||
$this->add_path('/moodle_backup/information', true); // Everything will be grouped below this | ||
$this->add_path('/moodle_backup/information/details/detail'); | ||
$this->add_path('/moodle_backup/information/contents/activities/activity'); | ||
$this->add_path('/moodle_backup/information/contents/sections/section'); | ||
$this->add_path('/moodle_backup/information/contents/course'); | ||
$this->add_path('/moodle_backup/information/settings/setting'); | ||
} | ||
|
||
protected function dispatch_chunk($data) { | ||
$this->accumchunks[] = $data; | ||
} | ||
|
||
public function get_all_chunks() { | ||
return $this->accumchunks; | ||
} | ||
|
||
} |
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