Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 10 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| ClientConfigService | |
0.00% |
0 / 10 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
| getExtendedConfig | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
| setClientConfig | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
6 | |||
| 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) 2016 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | namespace oat\tao\model\clientConfig; |
| 23 | |
| 24 | use oat\oatbox\service\ConfigurableService; |
| 25 | |
| 26 | /** |
| 27 | * |
| 28 | * @author Joel Bout |
| 29 | */ |
| 30 | class ClientConfigService extends ConfigurableService |
| 31 | { |
| 32 | public const SERVICE_ID = 'tao/clientConfig'; |
| 33 | |
| 34 | public const OPTION_CONFIG_SOURCES = 'configs'; |
| 35 | |
| 36 | /** |
| 37 | * Returns an array of json serialisable content |
| 38 | * to be send to the client json encoded |
| 39 | * |
| 40 | * @return array |
| 41 | */ |
| 42 | public function getExtendedConfig() |
| 43 | { |
| 44 | $config = []; |
| 45 | foreach ($this->getOption(self::OPTION_CONFIG_SOURCES) as $key => $source) { |
| 46 | $config[$key] = $source->getConfig(); |
| 47 | } |
| 48 | return $config; |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Either adds or overrides an existing client config |
| 53 | * |
| 54 | * @param string $id |
| 55 | * @param ClientConfig $configSource |
| 56 | */ |
| 57 | public function setClientConfig($id, ClientConfig $configSource) |
| 58 | { |
| 59 | $sources = $this->hasOption(self::OPTION_CONFIG_SOURCES) |
| 60 | ? $this->getOption(self::OPTION_CONFIG_SOURCES) |
| 61 | : [] |
| 62 | ; |
| 63 | $sources[$id] = $configSource; |
| 64 | $this->setOption(self::OPTION_CONFIG_SOURCES, $sources); |
| 65 | } |
| 66 | } |