aboutsummaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorValentin Popov <info@valentineus.link>2018-09-20 17:05:02 +0300
committerValentin Popov <info@valentineus.link>2018-09-20 17:05:02 +0300
commit36ddf415c40aee485e432be6925d14e71690fc39 (patch)
tree64d3e3d926d4be187a11477002d1507e1c3a1f1c /classes
parent67cf87d17c68af817b565ec567fbcd2716bcbcbe (diff)
downloadlocal_webhooks-36ddf415c40aee485e432be6925d14e71690fc39.tar.xz
local_webhooks-36ddf415c40aee485e432be6925d14e71690fc39.zip
Reducing nesting in the code
Signed-off-by: Valentin Popov <info@valentineus.link>
Diffstat (limited to 'classes')
-rw-r--r--classes/task/process_events_task.php20
1 files changed, 11 insertions, 9 deletions
diff --git a/classes/task/process_events_task.php b/classes/task/process_events_task.php
index d2d1ca9..84b5c88 100644
--- a/classes/task/process_events_task.php
+++ b/classes/task/process_events_task.php
@@ -45,18 +45,20 @@ class process_events_task extends \core\task\adhoc_task {
$services = \local_webhooks_api::get_services_by_event( $this->get_custom_data()->eventname );
foreach ( $services as $service ) {
- if ( !empty( $service->status ) ) {
- $curl = new \curl();
+ if ( empty( $service->status ) ) {
+ return;
+ }
- $event = (array) $this->get_custom_data();
- $event[ "token" ] = $service->token;
+ $curl = new \curl();
- $curl->setHeader( array( "Content-Type: " . $service->header ) );
- $curl->post( $service->point, json_encode( $event ) );
+ $event = (array) $this->get_custom_data();
+ $event[ "token" ] = $service->token;
- // TODO: Mark the log
- $curl->getResponse();
- }
+ $curl->setHeader( array( "Content-Type: " . $service->header ) );
+ $curl->post( $service->point, json_encode( $event ) );
+
+ // TODO: Mark the log
+ $curl->getResponse();
}
}
} \ No newline at end of file