MDL-57273 core: Exporters support custom formatting parameters

This commit is contained in:
Frederic Massart
2017-01-20 12:56:19 +08:00
committed by Damyon Wiese
parent 268beda8e9
commit 4bc68a416e
16 changed files with 334 additions and 30 deletions
+29
View File
@@ -24,6 +24,7 @@
namespace tool_lp\external;
defined('MOODLE_INTERNAL') || die();
use context_system;
/**
* Class for exporting path_node data.
@@ -33,6 +34,34 @@ defined('MOODLE_INTERNAL') || die();
*/
class path_node_exporter extends \core\external\exporter {
/**
* Constructor - saves the persistent object, and the related objects.
*
* @param mixed $data The data.
* @param array $related Array of relateds.
*/
public function __construct($data, $related = array()) {
if (!isset($related['context'])) {
// Previous code was automatically using the system context which was not always correct.
// We let developers know that they must fix their code without breaking anything,
// and fallback on the previous behaviour. This should be removed at a later stage: Moodle 3.5.
debugging('Missing related context in path_node_exporter.', DEBUG_DEVELOPER);
$related['context'] = context_system::instance();
}
parent::__construct($data, $related);
}
/**
* Return the list of properties.
*
* @return array
*/
protected static function define_related() {
return [
'context' => 'context'
];
}
/**
* Return the list of properties.
*