From fc6b6b83ea3a315a3acad6d79148b0d3cb22a9af Mon Sep 17 00:00:00 2001 From: Christian Date: Fri, 9 Jul 2021 11:40:23 -0500 Subject: [PATCH] Plugin : Improve install tables --- plugin/lti_provider/LtiProviderPlugin.php | 27 ++++++++++++++--------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/plugin/lti_provider/LtiProviderPlugin.php b/plugin/lti_provider/LtiProviderPlugin.php index 03ec1d65b7..b3a5b5b3cd 100644 --- a/plugin/lti_provider/LtiProviderPlugin.php +++ b/plugin/lti_provider/LtiProviderPlugin.php @@ -23,22 +23,22 @@ class LtiProviderPlugin extends Plugin $version = '1.0'; $author = 'Christian Beeznest'; - $publicKey = $this->getPublicKey(); $message = Display::return_message($this->get_lang('Description')); - if (empty($publicKey)) { - $publicKey = $this->get_lang('GenerateKeyPairInfo'); - } + if ($this->areTablesCreated()) { + $publicKey = $this->getPublicKey(); - $pkHtml = '
+ $pkHtml = '
+ .$this->get_lang('PublicKey').'
'.$publicKey.'
-

'; + } else { + $pkHtml = $this->get_lang('GenerateKeyPairInfo'); + } $settings = [ $message => 'html', @@ -137,10 +137,7 @@ class LtiProviderPlugin extends Plugin */ private function createPluginTables(): void { - $entityManager = Database::getManager(); - $connection = $entityManager->getConnection(); - - if ($connection->getSchemaManager()->tablesExist(self::TABLE_PLATFORM)) { + if ($this->areTablesCreated()) { return; } @@ -171,6 +168,14 @@ class LtiProviderPlugin extends Plugin } + private function areTablesCreated(): bool + { + $entityManager = Database::getManager(); + $connection = $entityManager->getConnection(); + + return $connection->getSchemaManager()->tablesExist(self::TABLE_PLATFORM); + } + /** * Save configuration for plugin. *