aboutsummaryrefslogtreecommitdiff
path: root/externallib.php
diff options
context:
space:
mode:
authorValentin Popov <info@valentineus.link>2018-02-22 11:44:50 +0300
committerValentin Popov <info@valentineus.link>2018-02-22 11:44:50 +0300
commit85bcb64e37128e07273d20252c86bc284b44a799 (patch)
tree2ba29a3a9af699bf8c9fd9e9e3a88d9e9228c377 /externallib.php
parent1736128dbf3be7fd83e6b3aa9088266aa8b490e6 (diff)
downloadlocal_webhooks-85bcb64e37128e07273d20252c86bc284b44a799.tar.xz
local_webhooks-85bcb64e37128e07273d20252c86bc284b44a799.zip
Added general list functions
Diffstat (limited to 'externallib.php')
-rw-r--r--externallib.php45
1 files changed, 25 insertions, 20 deletions
diff --git a/externallib.php b/externallib.php
index 246419f..e064c03 100644
--- a/externallib.php
+++ b/externallib.php
@@ -36,6 +36,29 @@ require_once($CFG->libdir . "/externallib.php");
*/
class local_webhooks_external extends external_api {
/**
+ * Formation of the final list.
+ *
+ * @param array $listrecords
+ * @return array
+ */
+ private static function formation_list($listrecords) {
+ $result = array();
+
+ foreach ($listrecords as $index => $record) {
+ $result[$index]["events"] = self::formation_events($record->events);
+ $result[$index]["enable"] = $record->enable;
+ $result[$index]["id"] = $record->id;
+ $result[$index]["other"] = $record->other;
+ $result[$index]["title"] = $record->title;
+ $result[$index]["token"] = $record->token;
+ $result[$index]["type"] = $record->type;
+ $result[$index]["url"] = $record->url;
+ }
+
+ return $result;
+ }
+
+ /**
* Formation of the final list of events.
*
* @param array $listevents
@@ -126,16 +149,7 @@ class local_webhooks_external extends external_api {
$result = array();
if ($listrecords = local_webhooks_search_services_by_event($parameters["eventname"], $parameters["active"])) {
- foreach ($listrecords as $index => $record) {
- $result[$index]["events"] = self::formation_events($record->events);
- $result[$index]["enable"] = $record->enable;
- $result[$index]["id"] = $record->id;
- $result[$index]["other"] = $record->other;
- $result[$index]["title"] = $record->title;
- $result[$index]["token"] = $record->token;
- $result[$index]["type"] = $record->type;
- $result[$index]["url"] = $record->url;
- }
+ $result = self::formation_list($listrecords);
}
return $result;
@@ -267,16 +281,7 @@ class local_webhooks_external extends external_api {
$result = array();
if ($listrecords = local_webhooks_get_list_records()) {
- foreach ($listrecords as $index => $record) {
- $result[$index]["events"] = self::formation_events($record->events);
- $result[$index]["enable"] = $record->enable;
- $result[$index]["id"] = $record->id;
- $result[$index]["other"] = $record->other;
- $result[$index]["title"] = $record->title;
- $result[$index]["token"] = $record->token;
- $result[$index]["type"] = $record->type;
- $result[$index]["url"] = $record->url;
- }
+ $result = self::formation_list($listrecords);
}
return $result;