aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin Popov <info@valentineus.link>2017-12-27 14:47:36 +0300
committerValentin Popov <info@valentineus.link>2017-12-27 14:47:36 +0300
commit41185c6db4e24b66b8773918a59683f132802744 (patch)
tree7656c86478dd35c090abaacb9260710cd851d45d
parent7e1284bfe2eb87e70aacf125186b86174ff63411 (diff)
downloadlocal_webhooks-41185c6db4e24b66b8773918a59683f132802744.tar.xz
local_webhooks-41185c6db4e24b66b8773918a59683f132802744.zip
Reconstructed external restore function from the backup
-rw-r--r--externallib.php18
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);
}
/**