From 41185c6db4e24b66b8773918a59683f132802744 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 27 Dec 2017 15:47:36 +0400 Subject: Reconstructed external restore function from the backup --- externallib.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'externallib.php') diff --git a/externallib.php b/externallib.php index cbe89dd..8acd3af 100644 --- a/externallib.php +++ b/externallib.php @@ -506,8 +506,12 @@ class local_webhooks_external extends external_api { public static function restore_backup_parameters() { return new external_function_parameters( array( - "backup" => new external_value(PARAM_TEXT, "Backup copy."), - "deleterecords" => new external_value(PARAM_BOOL, "Delete existing records.") + "options" => new external_single_structure( + array( + "backup" => new external_value(PARAM_TEXT, "Backup copy."), + "deleterecords" => new external_value(PARAM_BOOL, "Delete existing records.", VALUE_OPTIONAL) + ) + ) ) ); } @@ -515,18 +519,18 @@ class local_webhooks_external extends external_api { /** * Restore from a backup. * - * @param string $data - * @param boolean $deleterecords + * @param array $options * @since Moodle 2.9 Options available * @since Moodle 2.2 */ - public static function restore_backup($backup = "", $deleterecords = false) { - $parameters = self::validate_parameters(self::restore_backup_parameters(), array("backup" => $backup, "deleterecords" => $deleterecords)); + public static function restore_backup($options = array()) { + $parameters = self::validate_parameters(self::restore_backup_parameters(), array("options" => $options)); $context = context_system::instance(); self::validate_context($context); - local_webhooks_restore_backup($parameters["backup"], $parameters["deleterecords"]); + $deleterecords = !empty($parameters["options"]["deleterecords"]) ? boolval($parameters["options"]["deleterecords"]) : false; + local_webhooks_restore_backup($parameters["options"]["backup"], $deleterecords); } /** -- cgit v1.2.3