From 5eba0307dbdd15d1a215419ff9fd3e3f96f99f0e Mon Sep 17 00:00:00 2001 From: Khaled Lela Date: Fri, 11 Feb 2022 20:30:36 +0200 Subject: handle publish scorm runtime exception msg key as translation under resources/lang/en-US/scorm.php --- resources/lang/en-US/scorm.php | 17 +++++++++++++++++ src/ScormServiceProvider.php | 25 +++++++++++++++---------- 2 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 resources/lang/en-US/scorm.php diff --git a/resources/lang/en-US/scorm.php b/resources/lang/en-US/scorm.php new file mode 100644 index 0000000..9eb1c89 --- /dev/null +++ b/resources/lang/en-US/scorm.php @@ -0,0 +1,17 @@ + 'Invalid SCORM version.', + 'no_sco_in_scorm_archive_message' => 'No items in SCORM archive.', + 'invalid_scorm_data' => 'Invalid SCORM data.', + 'cannot_load_imsmanifest_message' => 'Can not load SCORM manifest.', + 'invalid_scorm_manifest_identifier' => 'Invalid SCORM manifest identifier.', + 'scorm_disk_not_define' => 'SCORM disk not define', + + // SCORM Items/Children messages** + 'default_organization_not_found_message' => 'SCORM item default organization not found.', + 'no_organization_found_message' => 'No organization found.', + 'sco_with_no_identifier_message' => 'SCORM item without identifier.', + 'sco_resource_without_href_message' => 'SCORM item resource without entry link.', + 'sco_without_resource_message' => 'SCORM item without resource.' +]; diff --git a/src/ScormServiceProvider.php b/src/ScormServiceProvider.php index 1806775..b50adc4 100644 --- a/src/ScormServiceProvider.php +++ b/src/ScormServiceProvider.php @@ -13,7 +13,7 @@ class ScormServiceProvider extends ServiceProvider { public function register() { - $this->app->bind('scorm-manager', function($app) { + $this->app->bind('scorm-manager', function ($app) { return new ScormManager(); }); } @@ -23,19 +23,24 @@ class ScormServiceProvider extends ServiceProvider $this->offerPublishing(); } - protected function offerPublishing() { + protected function offerPublishing() + { // function not available and 'publish' not relevant in Lumen - if (! function_exists('config_path')) { + if (!function_exists('config_path')) { return; } $this->publishes([ - __DIR__.'/../config/scorm.php' => config_path('scorm.php'), + __DIR__ . '/../config/scorm.php' => config_path('scorm.php'), ], 'config'); $this->publishes([ - __DIR__.'/../database/migrations/create_scorm_tables.php.stub' => $this->getMigrationFileName('create_scorm_tables.php'), + __DIR__ . '/../database/migrations/create_scorm_tables.php.stub' => $this->getMigrationFileName('create_scorm_tables.php'), ], 'migrations'); + + $this->publishes([ + __DIR__ . '/../resources/lang/en-US/scorm.php' => resource_path('lang/en-US/scorm.php'), + ]); } /** @@ -49,14 +54,14 @@ class ScormServiceProvider extends ServiceProvider $filesystem = $this->app->make(Filesystem::class); - return Collection::make($this->app->databasePath().DIRECTORY_SEPARATOR.'migrations'.DIRECTORY_SEPARATOR) + return Collection::make($this->app->databasePath() . DIRECTORY_SEPARATOR . 'migrations' . DIRECTORY_SEPARATOR) ->flatMap(function ($path) use ($filesystem) { - return $filesystem->glob($path.'*_create_scorm_tables.php'); - })->push($this->app->databasePath()."/migrations/{$timestamp}_create_scorm_tables.php") + return $filesystem->glob($path . '*_create_scorm_tables.php'); + })->push($this->app->databasePath() . "/migrations/{$timestamp}_create_scorm_tables.php") ->flatMap(function ($path) use ($filesystem, $migrationFileName) { - return $filesystem->glob($path.'*_'.$migrationFileName); + return $filesystem->glob($path . '*_' . $migrationFileName); }) - ->push($this->app->databasePath()."/migrations/{$timestamp}_{$migrationFileName}") + ->push($this->app->databasePath() . "/migrations/{$timestamp}_{$migrationFileName}") ->first(); } } -- cgit v1.2.3