Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| ClientLibConfigRegistry | |
0.00% |
0 / 8 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 1 |
| getConfigId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getExtension | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| register | |
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) 2015 (original work) Open Assessment Technologies SA; |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | namespace oat\tao\model; |
| 23 | |
| 24 | use oat\oatbox\AbstractRegistry; |
| 25 | use common_ext_ExtensionsManager; |
| 26 | |
| 27 | /** |
| 28 | * |
| 29 | * Registry to store client library config that will be provide to requireJs |
| 30 | * |
| 31 | * @author Sam, sam@taotesting.com |
| 32 | */ |
| 33 | class ClientLibConfigRegistry extends AbstractRegistry |
| 34 | { |
| 35 | /** |
| 36 | * @see \oat\oatbox\AbstractRegistry::getConfigId() |
| 37 | */ |
| 38 | protected function getConfigId() |
| 39 | { |
| 40 | return 'client_lib_config_registry'; |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * @see \oat\oatbox\AbstractRegistry::getExtension() |
| 45 | */ |
| 46 | protected function getExtension() |
| 47 | { |
| 48 | return common_ext_ExtensionsManager::singleton()->getExtensionById('tao'); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Register a new path for given alias, trigger a warning if path already register |
| 53 | * |
| 54 | * @author Sam, sam@taotesting.com |
| 55 | * @param string $id |
| 56 | * @param string|array $newLibConfig |
| 57 | */ |
| 58 | public function register($id, $newLibConfig) |
| 59 | { |
| 60 | $registry = self::getRegistry(); |
| 61 | $libConfig = []; |
| 62 | if ($registry->isRegistered($id)) { |
| 63 | $libConfig = $registry->get($id); |
| 64 | } |
| 65 | |
| 66 | $libConfig = array_replace_recursive($libConfig, $newLibConfig); |
| 67 | $registry->set($id, $libConfig); |
| 68 | } |
| 69 | } |