diff --git a/manifest.php b/manifest.php index 021c27e9..cb1145e9 100755 --- a/manifest.php +++ b/manifest.php @@ -30,6 +30,7 @@ use oat\taoLti\scripts\install\CreateLti1p3RegistrationSnapshotSchema; use oat\taoLti\scripts\install\GenerateKeys; use oat\taoLti\scripts\install\GenerisSearchWhitelist; +use oat\taoLti\scripts\install\RegisterPortalTheme; use oat\taoLti\scripts\install\SetupServices; use oat\taoLti\scripts\install\MapLtiSectionVisibility; use oat\taoLti\scripts\update\Updater; @@ -66,6 +67,7 @@ MapLtiSectionVisibility::class, GenerisSearchWhitelist::class, CreateLti1p3RegistrationSnapshotSchema::class, + RegisterPortalTheme::class ] ], 'update' => Updater::class, diff --git a/migrations/Version202406060802293772_taoLti.php b/migrations/Version202406060802293772_taoLti.php new file mode 100644 index 00000000..8666a5dc --- /dev/null +++ b/migrations/Version202406060802293772_taoLti.php @@ -0,0 +1,33 @@ +runAction(new RegisterPortalTheme()); + } + + public function down(Schema $schema): void + { + $this->throwIrreversibleMigrationException(); + } +} diff --git a/models/classes/theme/PortalThemeService.php b/models/classes/theme/PortalThemeService.php new file mode 100644 index 00000000..2381084e --- /dev/null +++ b/models/classes/theme/PortalThemeService.php @@ -0,0 +1,48 @@ +isSessionFromPortal()) { + return PortalTheme::THEME_ID; + } + + return $this->getOption(static::OPTION_CURRENT); + } + + private function isSessionFromPortal(): bool + { + $session = common_session_SessionManager::getSession(); + return $session instanceof TaoLtiSession + && !empty($session->getContexts(TenantDataSessionContext::class)); + } +} diff --git a/scripts/install/RegisterPortalTheme.php b/scripts/install/RegisterPortalTheme.php new file mode 100644 index 00000000..12760d7e --- /dev/null +++ b/scripts/install/RegisterPortalTheme.php @@ -0,0 +1,45 @@ +getServiceManager()->get(ThemeServiceInterface::SERVICE_ID); + + /** @var ThemeServiceInterface $service */ + $service = $this->propagate(new PortalThemeService()); + $service->setOptions($previousThemeService->getOptions()); + $service->addTheme(new PortalTheme(), false); + + $this->getServiceManager()->register(ThemeServiceInterface::SERVICE_ID, $service); + } +}