-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace oat\taoLti\migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use oat\tao\scripts\tools\migrations\AbstractMigration; | ||
use oat\taoLti\scripts\install\RegisterPortalTheme; | ||
use oat\taoQtiTest\scripts\install\RegisterQtiPackageExporter; | ||
|
||
/** | ||
* Auto-generated Migration: Please modify to your needs! | ||
* | ||
* phpcs:disable Squiz.Classes.ValidClassName | ||
*/ | ||
final class Version202406060802293772_taoLti extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return ''; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
$this->runAction(new RegisterPortalTheme()); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
$this->throwIrreversibleMigrationException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
/** | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; under version 2 | ||
* of the License (non-upgradable). | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
* | ||
* Copyright (c) 2024 (original work) Open Assessment Technologies SA; | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace oat\taoLti\models\classes\theme; | ||
|
||
use common_session_SessionManager; | ||
use oat\tao\model\session\Context\TenantDataSessionContext; | ||
use oat\tao\model\theme\PortalTheme; | ||
use oat\tao\model\theme\ThemeService; | ||
use oat\taoLti\models\classes\TaoLtiSession; | ||
|
||
class PortalThemeService extends ThemeService | ||
{ | ||
public function getCurrentThemeId() | ||
{ | ||
if ($this->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)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
/** | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; under version 2 | ||
* of the License (non-upgradable). | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
* | ||
* Copyright (c) 2024 (original work) Open Assessment Technologies SA; | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace oat\taoLti\scripts\install; | ||
|
||
use oat\oatbox\config\ConfigurationService; | ||
use oat\oatbox\extension\InstallAction; | ||
use oat\tao\model\theme\PortalTheme; | ||
use oat\tao\model\theme\ThemeServiceInterface; | ||
use oat\taoLti\models\classes\theme\PortalThemeService; | ||
|
||
class RegisterPortalTheme extends InstallAction | ||
{ | ||
public function __invoke($params = []) | ||
{ | ||
/** @var ConfigurationService $previousThemeService */ | ||
$previousThemeService = $this->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); | ||
} | ||
} |