Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 5 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| ArgumentService | |
0.00% |
0 / 5 |
|
0.00% |
0 / 2 |
30 | |
0.00% |
0 / 1 |
| load | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
| getOptionArguments | |
0.00% |
0 / 1 |
|
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) 2017 (original work) Open Assessment Technologies SA |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | namespace oat\tao\model\cliArgument; |
| 23 | |
| 24 | use oat\oatbox\action\Action; |
| 25 | use oat\tao\model\cliArgument\argument\Argument; |
| 26 | |
| 27 | class ArgumentService extends ArgumentLoader |
| 28 | { |
| 29 | public const SERVICE_ID = 'tao/cliArgumentLoader'; |
| 30 | |
| 31 | public const ARGUMENT_OPTION = 'arguments'; |
| 32 | |
| 33 | /** |
| 34 | * Get arguments from config and check if there are applicable |
| 35 | * In case of yes, process them |
| 36 | * |
| 37 | * @param Action $action |
| 38 | * @param array $params |
| 39 | */ |
| 40 | public function load(Action $action, array $params) |
| 41 | { |
| 42 | /** @var Argument $argument */ |
| 43 | foreach ($this->getArguments() as $argument) { |
| 44 | if ($argument->isApplicable($params)) { |
| 45 | $this->getServiceManager()->propagate($argument); |
| 46 | $argument->load($action); |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Get list of serialized arguments from options |
| 53 | * |
| 54 | * @return array |
| 55 | */ |
| 56 | protected function getOptionArguments() |
| 57 | { |
| 58 | return $this->hasOption(self::ARGUMENT_OPTION) ? $this->getOption(self::ARGUMENT_OPTION) : []; |
| 59 | } |
| 60 | } |