diff options
author | Valentin Popov <info@valentineus.link> | 2017-12-27 14:47:36 +0300 |
---|---|---|
committer | Valentin Popov <info@valentineus.link> | 2017-12-27 14:47:36 +0300 |
commit | 41185c6db4e24b66b8773918a59683f132802744 (patch) | |
tree | 7656c86478dd35c090abaacb9260710cd851d45d /externallib.php | |
parent | 7e1284bfe2eb87e70aacf125186b86174ff63411 (diff) | |
download | local_webhooks-41185c6db4e24b66b8773918a59683f132802744.tar.xz local_webhooks-41185c6db4e24b66b8773918a59683f132802744.zip |
Reconstructed external restore function from the backup
Diffstat (limited to 'externallib.php')
-rw-r--r-- | externallib.php | 18 |
1 files changed, 11 insertions, 7 deletions
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); } /** |