Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
42.86% |
3 / 7 |
|
42.86% |
3 / 7 |
CRAP | |
0.00% |
0 / 1 |
| AbstractProviderService | |
42.86% |
3 / 7 |
|
42.86% |
3 / 7 |
16.14 | |
0.00% |
0 / 1 |
| createFromArray | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getAllProviders | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getProvider | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| activateProvider | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| deactivateProvider | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| registerProviders | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| registerProvidersByCategories | |
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) 2017 (original work) Open Assessment Technologies SA; |
| 19 | */ |
| 20 | |
| 21 | namespace oat\tao\model\providers; |
| 22 | |
| 23 | use oat\tao\model\modules\AbstractModuleService; |
| 24 | |
| 25 | /** |
| 26 | * Manage module providers. Should be overridden to provide the right ProviderRegistry instance and a SERVICE_ID |
| 27 | * constant. |
| 28 | * |
| 29 | * @author Bertrand Chevrier <bertrand@taotesting.com> |
| 30 | * @author Jean-Sébastien Conan <jean-sebastien@taotesting.com> |
| 31 | */ |
| 32 | abstract class AbstractProviderService extends AbstractModuleService |
| 33 | { |
| 34 | /** |
| 35 | * Creates a provider object from data array |
| 36 | * @param $data |
| 37 | * @return ProviderModule |
| 38 | * @throws \common_exception_InconsistentData |
| 39 | */ |
| 40 | protected function createFromArray($data) |
| 41 | { |
| 42 | return ProviderModule::fromArray($data); |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Retrieves the list of all available providers (from the registry) |
| 47 | * |
| 48 | * @return ProviderModule[] the available providers |
| 49 | */ |
| 50 | public function getAllProviders() |
| 51 | { |
| 52 | return parent::getAllModules(); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Retrieves the given provider from the registry |
| 57 | * |
| 58 | * @param string $id the identifier of the provider to retrieve |
| 59 | * @return ProviderModule|null the provider |
| 60 | */ |
| 61 | public function getProvider($id) |
| 62 | { |
| 63 | return parent::getModule($id); |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Changes the state of a provider to active |
| 68 | * |
| 69 | * @param ProviderModule $provider the provider to activate |
| 70 | * @return boolean true if activated |
| 71 | */ |
| 72 | public function activateProvider(ProviderModule $provider) |
| 73 | { |
| 74 | return parent::activateModule($provider); |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Changes the state of a provider to inactive |
| 79 | * |
| 80 | * @param ProviderModule $provider the provider to deactivate |
| 81 | * @return boolean true if deactivated |
| 82 | */ |
| 83 | public function deactivateProvider(ProviderModule $provider) |
| 84 | { |
| 85 | return parent::deactivateModule($provider); |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * Registers a list of providers |
| 90 | * @param array $providers |
| 91 | * @return int The number of registered providers |
| 92 | * @throws \common_exception_InconsistentData |
| 93 | */ |
| 94 | public function registerProviders(array $providers) |
| 95 | { |
| 96 | return $this->registerModules($providers); |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Registers a list of providers gathered by categories |
| 101 | * @param array $providers |
| 102 | * @return int The number of registered providers |
| 103 | * @throws \common_exception_InconsistentData |
| 104 | * @throws \common_exception_InvalidArgumentType |
| 105 | */ |
| 106 | public function registerProvidersByCategories(array $providers) |
| 107 | { |
| 108 | return $this->registerModulesByCategories($providers); |
| 109 | } |
| 110 | } |