Code Coverage  | 
      ||||||||||
Lines  | 
       Functions and Methods  | 
       Classes and Traits  | 
      ||||||||
| Total |         | 
       0.00%  | 
       0 / 11  | 
               | 
       0.00%  | 
       0 / 4  | 
       CRAP |         | 
       0.00%  | 
       0 / 1  | 
      
| ModelManager |         | 
       0.00%  | 
       0 / 11  | 
               | 
       0.00%  | 
       0 / 4  | 
       56 |         | 
       0.00%  | 
       0 / 1  | 
      
| getModel |         | 
       0.00%  | 
       0 / 1  | 
               | 
       0.00%  | 
       0 / 1  | 
       2 | |||
| setModel |         | 
       0.00%  | 
       0 / 1  | 
               | 
       0.00%  | 
       0 / 1  | 
       2 | |||
| model2array |         | 
       0.00%  | 
       0 / 5  | 
               | 
       0.00%  | 
       0 / 1  | 
       2 | |||
| array2model |         | 
       0.00%  | 
       0 / 4  | 
               | 
       0.00%  | 
       0 / 1  | 
       20 | |||
| 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) 2002-2008 (original work) 2014 Open Assessment Technologies SA | 
| 19 | * | 
| 20 | */ | 
| 21 | |
| 22 | namespace oat\generis\model\data; | 
| 23 | |
| 24 | use oat\oatbox\service\ServiceManager; | 
| 25 | |
| 26 | /** | 
| 27 | * transitory class to manage the ontology driver | 
| 28 | * instead of managing full models, it only handles the rdfs interfaces | 
| 29 | * | 
| 30 | * @author Joel Bout <joel@taotesting.com> | 
| 31 | * @deprecated | 
| 32 | */ | 
| 33 | class ModelManager | 
| 34 | { | 
| 35 | public const CONFIG_KEY = 'ontology'; | 
| 36 | |
| 37 | /** | 
| 38 | * @return Model | 
| 39 | */ | 
| 40 | public static function getModel() | 
| 41 | { | 
| 42 | return ServiceManager::getServiceManager()->get(Ontology::SERVICE_ID); | 
| 43 | } | 
| 44 | |
| 45 | /** | 
| 46 | * @param Ontology $model | 
| 47 | */ | 
| 48 | public static function setModel(Model $model) | 
| 49 | { | 
| 50 | return ServiceManager::getServiceManager()->register(Ontology::SERVICE_ID, $model); | 
| 51 | } | 
| 52 | |
| 53 | protected static function model2array(Model $model) | 
| 54 | { | 
| 55 | $className = get_class($model); | 
| 56 | return [ | 
| 57 | 'class' => $className, | 
| 58 | 'config' => $model->getOptions() | 
| 59 | ]; | 
| 60 | } | 
| 61 | |
| 62 | protected static function array2model($array) | 
| 63 | { | 
| 64 | if (!isset($array['class']) || !isset($array['config']) || !is_array($array['config'])) { | 
| 65 | throw new \common_exception_Error('Illegal model array'); | 
| 66 | } | 
| 67 | $className = $array['class']; | 
| 68 | return new $className($array['config']); | 
| 69 | } | 
| 70 | } |