diff --git a/classes/form/create_sync_job.php b/classes/form/create_sync_job.php index 72fdca7..12d450c 100644 --- a/classes/form/create_sync_job.php +++ b/classes/form/create_sync_job.php @@ -76,8 +76,9 @@ public function definition(): void { $roleoptions[$role->id] = $role->localname; } + $iliosclient = di::get(ilios::class); + try { - $iliosclient = di::get(ilios::class); $iliosschools = $iliosclient->get_schools(); if (!empty($iliosschools)) { $iliosschools = array_column($iliosschools, 'title', 'id'); diff --git a/classes/task/sync_task.php b/classes/task/sync_task.php index a01386b..2a19e8a 100644 --- a/classes/task/sync_task.php +++ b/classes/task/sync_task.php @@ -77,12 +77,7 @@ public function execute(): void { return; } - try { - $iliosclient = di::get(ilios::class); - } catch (Exception $e) { - // Re-throw exception. - throw new Exception('ERROR: Failed to instantiate Ilios client.', $e); - } + $iliosclient = di::get(ilios::class); // Run enabled each sync job. foreach ($syncjobs as $syncjob) {