| Server IP : 165.22.154.248 / Your IP : 216.73.217.150 [ Web Server : Apache/2.4.29 (Ubuntu) System : Linux droplet-integra 4.15.0-197-generic #208-Ubuntu SMP Tue Nov 1 17:23:37 UTC 2022 x86_64 User : www-data ( 33) PHP Version : 7.2.24-0ubuntu0.18.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals, Domains : 1 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/avanza-lms.old.bak9874115/lib/classes/external/ |
Upload File : |
<?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/>.
/**
* Exporter based on persistent.
*
* @package core
* @copyright 2015 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\external;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir . '/externallib.php');
use coding_exception;
/**
* Abstract exporter based on the persistent model.
*
* This automatically fills in the properties of the exporter from those of the persistent.
*
* @copyright 2015 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class persistent_exporter extends exporter {
/** @var \core\persistent The persistent object we will export. */
protected $persistent = null;
/**
* Constructor - saves the persistent object, and the related objects.
*
* @param \core\persistent $persistent The persistent object to export.
* @param array $related - An optional list of pre-loaded objects related to this persistent.
*/
public function __construct(\core\persistent $persistent, $related = array()) {
$classname = static::define_class();
if (!$persistent instanceof $classname) {
throw new coding_exception('Invalid type for persistent. ' .
'Expected: ' . $classname . ' got: ' . get_class($persistent));
}
$this->persistent = $persistent;
if (method_exists($this->persistent, 'get_context') && !isset($this->related['context'])) {
$this->related['context'] = $this->persistent->get_context();
}
$data = $persistent->to_record();
parent::__construct($data, $related);
}
/**
* Persistent exporters get their standard properties from the persistent class.
*
* @return array Keys are the property names, and value their definition.
*/
protected final static function define_properties() {
$classname = static::define_class();
return $classname::properties_definition();
}
/**
* Returns the specific class the persistent should be an instance of.
*
* @return string
*/
protected static function define_class() {
throw new coding_exception('define_class() must be overidden.');
}
}