diff options
author | Valentin Popov <info@valentineus.link> | 2018-10-22 01:17:12 +0300 |
---|---|---|
committer | Valentin Popov <info@valentineus.link> | 2018-10-22 01:59:06 +0300 |
commit | 1352b5ee796c9a9e106cb9746b9201e8038b6210 (patch) | |
tree | c922ed9bacd8b2ac0d278cb44697ade9124b380f /classes/task | |
parent | f3b5ab561616ce42c5ddff11b632635a1c71f88f (diff) | |
download | local_webhooks-1352b5ee796c9a9e106cb9746b9201e8038b6210.tar.xz local_webhooks-1352b5ee796c9a9e106cb9746b9201e8038b6210.zip |
Code style fix
Signed-off-by: Valentin Popov <info@valentineus.link>
Diffstat (limited to 'classes/task')
-rw-r--r-- | classes/task/process_events_task.php | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/classes/task/process_events_task.php b/classes/task/process_events_task.php index 84b5c88..02e54a2 100644 --- a/classes/task/process_events_task.php +++ b/classes/task/process_events_task.php @@ -24,7 +24,11 @@ namespace local_webhooks\task; -defined( "MOODLE_INTERNAL" ) || die(); +global $CFG; + +require_once $CFG->dirroot . '/local/webhooks/lib.php'; + +defined('MOODLE_INTERNAL') || die(); /** * Class process_events_task @@ -36,26 +40,25 @@ defined( "MOODLE_INTERNAL" ) || die(); class process_events_task extends \core\task\adhoc_task { /** * Task handler. + * + * @throws \dml_exception + * @throws \moodle_exception */ public function execute() { - global $CFG; - - require_once( $CFG->dirroot . "/local/webhooks/lib.php" ); - - $services = \local_webhooks_api::get_services_by_event( $this->get_custom_data()->eventname ); + $services = \local_webhooks_api::get_services_by_event($this->get_custom_data()->eventname); - foreach ( $services as $service ) { - if ( empty( $service->status ) ) { + foreach ($services as $service) { + if ((bool) $service->status !== true) { return; } $curl = new \curl(); $event = (array) $this->get_custom_data(); - $event[ "token" ] = $service->token; + $event['token'] = $service->token; - $curl->setHeader( array( "Content-Type: " . $service->header ) ); - $curl->post( $service->point, json_encode( $event ) ); + $curl->setHeader(array('Content-Type: ' . $service->header)); + $curl->post($service->point, json_encode($event)); // TODO: Mark the log $curl->getResponse(); |