Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 14 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| tao_actions_ClientConfig | |
0.00% |
0 / 14 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
| config | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
6 | |||
| getClientConfigStorage | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2013-2023 (original work) Open Assessment Technologies SA. |
| 19 | */ |
| 20 | |
| 21 | declare(strict_types=1); |
| 22 | |
| 23 | use oat\tao\model\clientConfig\GetConfigQuery; |
| 24 | use oat\tao\model\clientConfig\ClientConfigStorage; |
| 25 | |
| 26 | /** |
| 27 | * Generates client side configuration. |
| 28 | * |
| 29 | * @author Bertrand Chevrier <bertrand@taotesting.com> |
| 30 | * @license GPLv2 http://www.opensource.org/licenses/gpl-2.0.php |
| 31 | * |
| 32 | * phpcs:disable Squiz.Classes.ValidClassName |
| 33 | */ |
| 34 | class tao_actions_ClientConfig extends tao_actions_CommonModule |
| 35 | { |
| 36 | /** |
| 37 | * Get the require.js' config file |
| 38 | */ |
| 39 | public function config(): void |
| 40 | { |
| 41 | $this->setContentHeader('application/javascript'); |
| 42 | |
| 43 | $params = $this->getPsrRequest()->getQueryParams(); |
| 44 | |
| 45 | $getConfigQuery = new GetConfigQuery( |
| 46 | $params['extension'] ?? Context::getInstance()->getExtensionName(), |
| 47 | $params['action'] ?? Context::getInstance()->getActionName(), |
| 48 | $params['module'] ?? Context::getInstance()->getModuleName(), |
| 49 | $params['shownExtension'] ?? null, |
| 50 | $params['shownStructure'] ?? null |
| 51 | ); |
| 52 | $config = $this->getClientConfigStorage()->getConfig($getConfigQuery); |
| 53 | |
| 54 | foreach ($config as $key => $value) { |
| 55 | $this->setData($key, $value); |
| 56 | } |
| 57 | |
| 58 | $this->setView('client_config.tpl'); |
| 59 | } |
| 60 | |
| 61 | private function getClientConfigStorage(): ClientConfigStorage |
| 62 | { |
| 63 | return $this->getPsrContainer()->get(ClientConfigStorage::class); |
| 64 | } |
| 65 | } |