芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/.trash/cepali/lib/classes/external/persistent_exporter.php
. /** * 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.'); } }