From 0d41df6b5a59e20707e8d16b09275aea572de756 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Tue, 17 Apr 2018 00:05:14 +0800 Subject: [PATCH] MDL-61899 tool_dataprivacy: Create name-description exporter Create exporter for lawful bases that contain name and description pairs --- .../external/name_description_exporter.php | 63 +++++++++++++++++++ .../classes/external/purpose_exporter.php | 14 +---- 2 files changed, 65 insertions(+), 12 deletions(-) create mode 100644 admin/tool/dataprivacy/classes/external/name_description_exporter.php diff --git a/admin/tool/dataprivacy/classes/external/name_description_exporter.php b/admin/tool/dataprivacy/classes/external/name_description_exporter.php new file mode 100644 index 0000000000000..eeb39a23d80a1 --- /dev/null +++ b/admin/tool/dataprivacy/classes/external/name_description_exporter.php @@ -0,0 +1,63 @@ +. + +/** + * Class for exporting an object containing a name and a description. + * + * @package tool_dataprivacy + * @copyright 2018 Jun Pataleta + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +namespace tool_dataprivacy\external; +defined('MOODLE_INTERNAL') || die(); + +use core\external\exporter; + +/** + * Class that exports an object containing a name and a description. + * + * @copyright 2018 Jun Pataleta + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class name_description_exporter extends exporter { + + /** + * Returns a list of objects that are related. + * + * @return array + */ + protected static function define_related() { + return array( + 'context' => 'context', + ); + } + + /** + * Return the list of properties. + * + * @return array + */ + protected static function define_properties() { + return [ + 'name' => [ + 'type' => PARAM_TEXT, + ], + 'description' => [ + 'type' => PARAM_TEXT, + ], + ]; + } +} diff --git a/admin/tool/dataprivacy/classes/external/purpose_exporter.php b/admin/tool/dataprivacy/classes/external/purpose_exporter.php index e2f73c3b9a57d..f91e2f28b8d55 100644 --- a/admin/tool/dataprivacy/classes/external/purpose_exporter.php +++ b/admin/tool/dataprivacy/classes/external/purpose_exporter.php @@ -28,8 +28,6 @@ use core\external\persistent_exporter; use DateInterval; use Exception; -use external_single_structure; -use external_value; use renderer_base; use tool_dataprivacy\purpose; @@ -67,24 +65,16 @@ protected static function define_related() { * @return array */ protected static function define_other_properties() { - $namedescriptiontype = [ - 'name' => [ - 'type' => PARAM_TEXT, - ], - 'description' => [ - 'type' => PARAM_TEXT, - ], - ]; return [ 'formattedretentionperiod' => [ 'type' => PARAM_TEXT ], 'formattedlawfulbases' => [ - 'type' => $namedescriptiontype, + 'type' => name_description_exporter::read_properties_definition(), 'multiple' => true ], 'formattedsensitivedatareasons' => [ - 'type' => $namedescriptiontype, + 'type' => name_description_exporter::read_properties_definition(), 'multiple' => true, 'optional' => true ],