[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 3 // This file is part of Moodle - http://moodle.org/ 4 // 5 // Moodle is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // Moodle is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 17 18 /** 19 * @package moodlecore 20 * @subpackage backup-plan 21 * @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 /** 26 * Implementable class defining the needed stuf for one backup plan 27 * 28 * TODO: Finish phpdocs 29 */ 30 class backup_plan extends base_plan implements loggable { 31 32 protected $controller; // The backup controller building/executing this plan 33 protected $basepath; // Fullpath to dir where backup is created 34 protected $excludingdactivities; 35 36 /** 37 * Constructor - instantiates one object of this class 38 */ 39 public function __construct($controller) { 40 global $CFG; 41 42 if (! $controller instanceof backup_controller) { 43 throw new backup_plan_exception('wrong_backup_controller_specified'); 44 } 45 $this->controller = $controller; 46 $this->basepath = $CFG->tempdir . '/backup/' . $controller->get_backupid(); 47 $this->excludingdactivities = false; 48 parent::__construct('backup_plan'); 49 } 50 51 /** 52 * Destroy all circular references. It helps PHP 5.2 a lot! 53 */ 54 public function destroy() { 55 // No need to destroy anything recursively here, direct reset 56 $this->controller = null; 57 // Delegate to base plan the rest 58 parent::destroy(); 59 } 60 61 public function build() { 62 backup_factory::build_plan($this->controller); // Dispatch to correct format 63 $this->built = true; 64 } 65 66 public function get_backupid() { 67 return $this->controller->get_backupid(); 68 } 69 70 public function get_type() { 71 return $this->controller->get_type(); 72 } 73 74 public function get_mode() { 75 return $this->controller->get_mode(); 76 } 77 78 public function get_courseid() { 79 return $this->controller->get_courseid(); 80 } 81 82 public function get_basepath() { 83 return $this->basepath; 84 } 85 86 public function get_logger() { 87 return $this->controller->get_logger(); 88 } 89 90 /** 91 * Gets the progress reporter, which can be used to report progress within 92 * the backup or restore process. 93 * 94 * @return \core\progress\base Progress reporting object 95 */ 96 public function get_progress() { 97 return $this->controller->get_progress(); 98 } 99 100 public function is_excluding_activities() { 101 return $this->excludingdactivities; 102 } 103 104 public function set_excluding_activities() { 105 $this->excludingdactivities = true; 106 } 107 108 public function log($message, $level, $a = null, $depth = null, $display = false) { 109 backup_helper::log($message, $level, $a, $depth, $display, $this->get_logger()); 110 } 111 112 /** 113 * Function responsible for executing the tasks of any plan 114 */ 115 public function execute() { 116 if ($this->controller->get_status() != backup::STATUS_AWAITING) { 117 throw new backup_controller_exception('backup_not_executable_awaiting_required', $this->controller->get_status()); 118 } 119 $this->controller->set_status(backup::STATUS_EXECUTING); 120 parent::execute(); 121 $this->controller->set_status(backup::STATUS_FINISHED_OK); 122 } 123 } 124 125 /* 126 * Exception class used by all the @backup_plan stuff 127 */ 128 class backup_plan_exception extends base_plan_exception { 129 130 public function __construct($errorcode, $a=NULL, $debuginfo=null) { 131 parent::__construct($errorcode, $a, $debuginfo); 132 } 133 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |