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